tags:

views:

215

answers:

2

I have a ascx that looks like this:

<UpdatePanel Parent mode = Conditional>
  <UpdatePanel1 mode = Conditional>
    //A form here with textboxes, etc

    //A repeater here with a linkbutton that causes a postback

  </UpdatePanel1>
</UpdatePanel Parent>

In the OnItemCommand of the repeater, I get the form values and set them. It works fine but there is re-rendering of the form (ie., a flicker during which the form disappears and reappears). Why is this happening considering i have it in an UpdatePanel?

EDIT: I seem to have half solved the problem by separating the form and the repeater into its different updatepanels. But, the problem now is that the form doesnt get updated when I click on the linkbutton in the repeater even though the server side code runs.

EDIT AGAIN:

I think I know what's going on. I have 1 question before nailing this (hopefully). The form looks like this:

<tr>
  <td>
    <asp:checkbox id="chkSelect" runat="server" />
    <asp:label text="Something"   runat="server" />
    <asp:textbox id="txtSomething" runat="server" />
  </td>
</tr>
<tr>
  <td>
    <asp:checkbox id="chkSelect2" runat="server" />
    <asp:label text="Something2"   runat="server" />
    <asp:textbox id="txtSomething2" runat="server" />
  </td>
</tr>

All I care about when the linkbutton is clicked is to update ONLY the textbox controls. I want everything else to remain the way they were.

Is there a way to conditionally trigger updates only on those controls?

I understand I can use JS but would rather avoid it (as there's a lot of server side processing before I know the values of the textboxes)

@Roselberg - The state of the controls that I am NOT interested in, is actually set on the client side in one huge JS script that runs on load to which I really don't have much control over the script

A: 

If you want to conditionally update only the textboxes then you will need to place them in their own UpdatPanel. Make sure those UpdatePanels are triggered by your link button and everything should work fine.

Although I'm not really sure what you mean by

I want everything else to remain the way they were.

The checkboxes and labels will only change if you have code to change them during postback.

Daniel
1 updatepanel for each textbox? Isn't that an overkill? I would like to group all of them in one updatepanel, but the layout prevents me from doing this. I was hoping there's a way to specify a collection of controls that the UpdatePanel should update.
DotnetDude
There is no way to specify controls to update. They must be children of the UpdatePanel.
Daniel
A: 

The architecture of ASP.NET AJAX actually overwrites the entire html inside the UpdatePanel. It doesn't update values individually. Basically, there are three options for this:

  • Put the textboxes and checkboxes in seperate update panels. Looks like this won't work for your scenario.
  • Make sure to transfer the values on postback to ensure that the controls remain the same display. They will actually be overwritten, but if they are overwritten with the same value this shouldn't be noticable.
  • Use a different AJAX method that calls back to a handler, instead of using ASP.NET AJAX for these. Use javascript to call the handler, and then update the values individually instead of replacing the controls like ASP.NET AJAX does. This is easy with the jquery get method or client callbacks.
Chris Hynes
In the 3rd method, can I use jquery to call a eventhandler in the code behind? I haven't used the get method before :(
DotnetDude
You can call methods in codebehind using client callbacks (built in ASP.NET feature, not using jQuery). I added a link to an example in the last bullet above...
Chris Hynes