views:

247

answers:

1

i have a dynamically created gridview button that fires off a modal popup when clicked. I do this onclientside like so:

function openModal(btnId, v) {
deptdata(v);
   // __doPostBack('<%=DropDownList1.ClientID %>', '');
    btn = document.getElementById(btnId);
    btn.click();
}
function deptdata(v) {
    document.getElementById('<%=vendor.ClientID%>').value = v;

}

This is how the function is called in the code.

btnedit.OnClientClick = String.Format("openModal('{0}','" & GridView1.Rows(i).Cells(0).Text & "');return false;", hidden.ClientID)

I set the value of a hidden field(Vendor) but I need that value for what's in the modal popup. I have a dropdown list that depends on that newly set variable. The variable is set depending on what row was clicked. So i need to somehow just reload that popup. I have an Update Panel but I can't get that Panel to reload. I've tried __doPostback and it didn't help. any ideas how to update the panel or the dropdown in the panel using javascript?

A: 

It's not very clear from your description and the limited code you provide what it is exactly that you are trying to do and what is failing. However, the following might give you some ideas. If you provide more detail and code someone might be able to give you a better answer.

ScriptManager1.RegisterAsyncPostBackControl(Button1);

to trigger an update panel post back from js make sure you use UniqueID, not ClientID, thats a common gotcha that prevents the async postback from working.

__doPostBack("<%=Button1.UniqueID %>", "");

Personally, I have all but given up on UpdatePanels, I only use them in the most trivial cases. I prefer to have my js call an ASP.Net JSON webservice and have the on completed function render any needed changes to the html. It's more flexible, lighter and infinitely faster for pages with large grids or a lot of controls.

Tion