views:

813

answers:

1

Hello All, I have a user control whose structure is -

<updatepanel UpdateMode="Always">
<ContentTemplate>
   <asp:FormView>
    <EditItemTemplate>
       <table>
           <tr id='tr1'>
             <td>
                 Textbox1
                 btn1
             </td> 
           </tr> 
           <tr id='tr2'>
             <td>
                  textbox2
             </td> 
           </tr> 
        <table>
   </EditItemTemplate>
  </asp:FormView>
</ContentTemplate>
</updatepanel>

On page load I use following to hide tr2

ClientScriptManager cs = Page.ClientScript;
csText.AppendLine("");
csText.AppendLine("if(document.getElementById('tr2')!=null) 
           document.getElementById('tr2').style.display = 'none';");
csText.AppendLine("");
cs.RegisterStartupScript(this, this.GetType(), csName, csText.ToString(), false);

This part is working fine. Now on click of the btn1 I am popping up the modal popup extendar control. This causes the tr2 to show again. I know that the script needs to be inline with the updatePanel. I tried using ScriptManager.RegisterStartupScript(....); but does not work. Also the updateMode needs to be always so that the data from pop extendar can be put inside the Textbox1

All the help is appreciated. Thank you

A: 

Since you're using an UpdatePanel, you don't really need any javascript for this.

If you change your tr2 element to ...

<tr id="tr2" runat="server">

this will allow you to control it in your server side code. To hide your tr2 row, simply do...

tr2.Style["display"] = "none";

this should keep things in sync nicely on callbacks.

Antony Scott
This was my first solution.The problem with this is data is entered in the controls inside row(tr2),they donot get bound correctly.I mean the data is not received back after postback.I have a next button outside this outermost updatepanel.Onclick of which I'm firing custom event to get back the data