简体   繁体   English

谁能帮我这个? 在客户端部分刷新更新面板

[英]Can Anyone Help me with this? Refresh update panel partially onclient side

i have a dynamically created gridview button that fires off a modal popup when clicked. 我有一个动态创建的gridview按钮,当单击该按钮时会触发模式弹出窗口。 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. 我试过了__doPostback,它没有帮助。 any ideas how to update the panel or the dropdown in the panel using javascript? 任何想法如何使用javascript更新面板或面板中的下拉菜单?

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); 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. 要从js触发更新面板回发,请确保您使用的是UniqueID,而不是ClientID,这是阻止异步回发工作的常见陷阱。

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

Personally, I have all but given up on UpdatePanels, I only use them in the most trivial cases. 就个人而言,我几乎放弃了UpdatePanels,仅在最琐碎的情况下使用它们。 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. 我更喜欢让我的js调用ASP.Net JSON网络服务,并让oncomplete函数呈现对html的任何必要更改。 It's more flexible, lighter and infinitely faster for pages with large grids or a lot of controls. 对于具有大型网格或大量控件的页面,它更灵活,更轻巧,而且速度更快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM