This is a migrated thread and some comments may be shown as answers.

Set statusbar text

10 Answers 356 Views
Window
This is a migrated thread and some comments may be shown as answers.
wnl
Top achievements
Rank 1
wnl asked on 25 Jun 2009, 10:19 AM
Hi,
how to set custom text to statusbar in RadWindow?
Thanks:)

10 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jun 2009, 10:40 AM
Hello Jaromin,

Try the following approach for setting custom text for status bar of radwindow.

ASPX:
 
<telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="MyPage.aspx"   
    OnClientPageLoad="ClientShow" Title="My Title" VisibleOnPageLoad="True" >  
</telerik:RadWindow> 

JavaScript:
 
<script type="text/javascript">  
function ClientShow()  
{  
    var oWindow = $find("<%=RadWindow1.ClientID%>");    
    oWindow.set_status("Custom Text");  
}  
</script> 

Shinu.
0
wnl
Top achievements
Rank 1
answered on 01 Jul 2009, 09:16 AM
This code doesn't work at all.
I get:  

Server Error in '/RadWindowStatusBar' Application.

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

What is wrong?

0
Stuart Hemming
Top achievements
Rank 2
answered on 01 Jul 2009, 09:45 AM
Jaromin,

You need to make sure that the JavaScript is wrapped in either a <telerik:RadCodeBlock></telerik:RadCodeBlock> or <telerik:RadScriptBlock></telerik:RadScriptBlock> pair.

See this help page for more details.

--
Stuart
0
wnl
Top achievements
Rank 1
answered on 02 Jul 2009, 12:59 PM
It's work:)
The second task which I want to make is: How to pass some value ( string value from c# code) to set_status javascript function?
I prepare in c#: 
string status = "Some txt"

and I want to have statusbar with this text above.
How is the best way to achieve this?
0
Stuart Hemming
Top achievements
Rank 2
answered on 02 Jul 2009, 01:26 PM
Jaromin,

You haven't said how you're opening the window (directly from client-side or by making a JavaScript call from server-side) so it's not possible to say what id best for how you're operating.

However, one way would be to add a hidden field on the page that contains the RadWindow control.Then, in your code-behind, assign the value for your status bar text to that control. Finally, in your ClientShow JavaScript function, take the value from your hidden input and us it as the paramater to the set_status method.

Something like this:
Markup ...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication1.WebForm10" EnableEventValidation="false" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
  <title></title
</head> 
<body> 
  <form id="form1" runat="server"
  <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
  </telerik:RadScriptManager> 
  <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
 
    <script type="text/javascript"
      function ClientShow() { 
        var oWindow = $find("<%=RadWindow1.ClientID%>"); 
        var hiddenInput = $get("<%= HiddenField1.ClientID %>"); 
        oWindow.set_status(hiddenInput.value); 
      }   
    </script> 
 
  </telerik:RadScriptBlock> 
 
 
  <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="http://www.telerik.com"    
    OnClientPageLoad="ClientShow" Title="My Title" VisibleOnPageLoad="True" > 
  </telerik:RadWindow> 
  <asp:HiddenField ID="HiddenField1" runat="server" Value=""/> 
  </form> 
</body> 
</html> 

Code-behind ...
using System; 
 
namespace WebApplication1 
    public partial class WebForm10 : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            HiddenField1.Value = String.Format("The time is: {0}", DateTime.Now); 
        } 
    } 

Hope this helps.

--
Stuart
0
wnl
Top achievements
Rank 1
answered on 03 Jul 2009, 06:19 AM
Hi,
nice idea:) I'm opening with JavaScript call from server-side
Is the way to do this without hidden field and call set_status in Page_Load an then pass custom value?
0
Stuart Hemming
Top achievements
Rank 2
answered on 03 Jul 2009, 06:42 AM
If you're making a call to a function in JavaScript, pass the text to the function call as a parameter, then, I suppose, you could assign the text to a variable and use that variable in your ClientShow call.

There are many different ways to skin this particular cat.

--
Stuart
0
Fiko
Telerik team
answered on 08 Jul 2009, 11:42 AM
Hello Jaromin,

For your convenience I have prepared a simple project that demonstrates a possible solution without using HiddenField.
I am not quite sure what are the sequence of the steps that you take in order to change the status text, but please note the following scenario :

You open the window(by using radopen() or oWindow.show()) for the first time (or the ReloadOnShow is set to true), the content page(that is loaded inside the RadWindow)  is from the same domain and the content page contains text between its <title>  tags. In this case the following code does not change the status text of the newly opened RadWindow.

var oWindow = $find("<%= RadWindow1.ClientID %>");  
oWindow.show();  
oWindow.set_status(myStatusText); 

This is because of that the RadWindow control gets the value between the <title> tag of the content page(after it is loaded) and shows it as a status text. You can avoid this behavior by calling the  set_status function in the OnClientPageLoad event of the RadWindow(implemented in the attached demo).

I hope this helps.

Sincerely yours,

Fiko
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
wnl
Top achievements
Rank 1
answered on 16 Jul 2009, 09:26 AM
Is there possible to set status using only c# code without javascript?
0
Fiko
Telerik team
answered on 17 Jul 2009, 03:41 PM
Hello Jaromin,

The RadWindow control does not contain method or property that can be used in order to set the status text of the window. The approach showed in my previous answer is the only way to set a text (the value of the text is from the server) to the status bar of the RadWindow

Regards,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Window
Asked by
wnl
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
wnl
Top achievements
Rank 1
Stuart Hemming
Top achievements
Rank 2
Fiko
Telerik team
Share this question
or