如果多次使用,则WebUser Control不会显示Ajax网格. [英] WebUser Control not displaying Ajax grid if used more than once.

查看:54
本文介绍了如果多次使用,则WebUser Control不会显示Ajax网格.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个代表小部件的Web用户控件.用户控件由一些用于页眉和页脚的HTML组成,小部件的实际内容借助AJAX Gridview显示,该视图也放置在控件内部.我用Javascript绑定了gridview.如果我仅在Webform上使用一次控件,但一切使用似乎都正常,但是如果不止一次使用,则该页面仅显示用户控件中的HTML,而除了我放置的第一个位置之外,不显示其他控件的网格内容Web表单上的控件.如果我必须查看页面源代码,它会显示gridview id并生成HTML正文,并显示带有body标签的空表.

I created a web user control which represents a widget. The user control consists of some HTML for header and footer, the actual content of the widget is displayed with the help of an AJAX Gridview which is also placed inside the control. I bind the gridview with Javascript. Everything seems to work proper if i use the control just once on the webform but if used more than once the page only displays the HTML from the user control and does not show any grid content for the others except the very first place where i have placed the control on the webform. If i had to view the page source it shows the gridview id and generated HTML body just shows and empty table with a body tag. Is this an ambiguity issue or anything else i should be looking for while the control is being rendered?

推荐答案

你好!

我曾经在同一页面中添加两次用户控件时遇到问题.就我而言,由于我在用户控件中具有相同的ID,而javascript仅对第一个控件起作用,因此javascript函数不知道要引用哪个控件.
我通过更改控件的ID和更改javascript函数以查找控件的客户端ID来解决该问题,例如:

Hello!

I once had a problem with a user control I added twice in the same page. In my case, the javascript functions didn''t know which control to refer, due to the fact that I had the same ids in the user controls and the javascript only wokred for the first control.
I solved the problem by changing the controls'' ids and by changing the javascript function to look for the client id of the control, e.g.:

<br />
document.getElementById("<%=ControlName.ClientID%>")<br />



希望这会有所帮助!



Hope this helps a bit!


这篇关于如果多次使用,则WebUser Control不会显示Ajax网格.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆