Literal in UpdatePanel not updated if text has <

Last post 05-09-2008 2:51 PM by hpdotnet. 2 replies.

Sort Posts:

  • Literal in UpdatePanel not updated if text has <

    05-08-2008, 5:40 PM
    • Loading...
    • hpdotnet
    • Joined on 09-29-2006, 2:57 PM
    • Posts 18

    Hi,

    I have a UpdatePanel that includes a GridView and an asp:Literal object. After binding the GridView, I inject a javascript text in the Literal object. 

    literal.Text = "<script type=\"text/javascript\">" +
                String.Concat("var CheckBoxIDs = new Array(", String.Join(",",(string [])arrList.ToArray(typeof(string))), ");")  +
                                         "</script>";

     The javascript variable is used by other functions when the user clicks on checkboxes in the GridView.

    But for some reason, the Literal value does not gets updated. After further troubleshooting, I found that it does not like the "<" character.

    This works:

    literal.Text = String.Concat("var CheckBoxIDs = new Array(", String.Join(",",(string [])arrList.ToArray(typeof(string))), ");") ;
         

    But then how do I make this a page level javascript variable? Ideally I want to inject the script tag and the corresponding javascript within the script tags.

    Am I missing something here? Is there any other way to update javascript variables dynamically on async postback? 

    Thanks

    HP

     

     

     

     

     

     

  • Re: Literal in UpdatePanel not updated if text has <

    05-09-2008, 11:16 AM
    Answer
    • Loading...
    • gt1329a
    • Joined on 06-23-2002, 8:53 PM
    • Atlanta
    • Posts 1,523
    Check out ScriptManager.RegisterArrayDeclaration()
  • Re: Literal in UpdatePanel not updated if text has <

    05-09-2008, 2:51 PM
    Answer
    • Loading...
    • hpdotnet
    • Joined on 09-29-2006, 2:57 PM
    • Posts 18

     Excellent, that works!

    I am still exploring the .net API and was not aware of this new function.

    Appreciate your help!

    HP

     

Page 1 of 1 (3 items)