Set statusbar text

11 posts, 0 answers
  1. wnl
    wnl avatar
    106 posts
    Member since:
    Aug 2007

    Posted 25 Jun 2009 Link to this post

    Hi,
    how to set custom text to statusbar in RadWindow?
    Thanks:)
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Jun 2009 Link to this post

    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.
  3. wnl
    wnl avatar
    106 posts
    Member since:
    Aug 2007

    Posted 01 Jul 2009 Link to this post

    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?

  4. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 01 Jul 2009 Link to this post

    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
  5. wnl
    wnl avatar
    106 posts
    Member since:
    Aug 2007

    Posted 02 Jul 2009 Link to this post

    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?
  6. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 02 Jul 2009 Link to this post

    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 ...
    1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication1.WebForm10" EnableEventValidation="false" %> 
    2  
    3 <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    5 <html xmlns="http://www.w3.org/1999/xhtml"
    6 <head runat="server"
    7   <title></title
    8 </head> 
    9 <body> 
    10   <form id="form1" runat="server"
    11   <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    12   </telerik:RadScriptManager> 
    13   <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    14  
    15     <script type="text/javascript"
    16       function ClientShow() { 
    17         var oWindow = $find("<%=RadWindow1.ClientID%>"); 
    18         var hiddenInput = $get("<%= HiddenField1.ClientID %>"); 
    19         oWindow.set_status(hiddenInput.value); 
    20       }   
    21     </script> 
    22  
    23   </telerik:RadScriptBlock> 
    24  
    25  
    26   <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="http://www.telerik.com"    
    27     OnClientPageLoad="ClientShow" Title="My Title" VisibleOnPageLoad="True" > 
    28   </telerik:RadWindow> 
    29   <asp:HiddenField ID="HiddenField1" runat="server" Value=""/> 
    30   </form> 
    31 </body> 
    32 </html> 

    Code-behind ...
    1 using System; 
    2  
    3 namespace WebApplication1 
    4
    5     public partial class WebForm10 : System.Web.UI.Page 
    6     { 
    7         protected void Page_Load(object sender, EventArgs e) 
    8         { 
    9             HiddenField1.Value = String.Format("The time is: {0}", DateTime.Now); 
    10         } 
    11     } 
    12

    Hope this helps.

    --
    Stuart
  7. wnl
    wnl avatar
    106 posts
    Member since:
    Aug 2007

    Posted 03 Jul 2009 Link to this post

    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?
  8. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 03 Jul 2009 Link to this post

    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
  9. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 08 Jul 2009 Link to this post

    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.
  10. wnl
    wnl avatar
    106 posts
    Member since:
    Aug 2007

    Posted 16 Jul 2009 Link to this post

    Is there possible to set status using only c# code without javascript?
  11. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 17 Jul 2009 Link to this post

    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.
Back to Top