0

I have a repeater in UpdatePanel, and in it is a linkbutton that needs to set some values in a hidden div (display none) and then call javascript method that would make that div visible.

I am using ScriptManager.RegisterStartupScript and it is calling js method but the problem is that the code behind code is overwritten - code behind code is setting values for some fields from database (in the hidden div) and after it appears the fields are empty. If i click on a different button in repeater in updatepanel the div appears with the values set for a previous click. (the customer demand is that they click on a record in repeater and they can change it in a modal dialog).

how can i get the javascript method to make the modal dialog appear with the proper values?

current code is something like this in oncommand event for a repeater linkbutton

  ...
  txtName.Text = row.Name;
  ScriptManager.RegisterStartupScript(this, typeof(string), "showEdit", "showModalPanel('pnEdit')", true);
4

1 回答 1

0

我最近在让 ScriptManager.RegisterStartupScript 使用 UpdatePanel 处理部分回发时遇到了一些问题。尝试切换您的代码以使用类似的东西...

ScriptManager.RegisterClientScriptBlock(updPnl, updPnl.GetType(), updPnl.ClientID, "alert('hello world';", True)

您可能还必须在每次单击时手动更新 UpdatePanel,以便隐藏的 div 获得刷新的值。为此,您必须将 UpdatePanel 上的 UpdateMode 设置为 Conditional,然后确保在需要时在代码隐藏中返回并手动更新它。

于 2013-06-21T19:21:50.707 回答