从自定义用户控件更新contenttemplate下页面中控件的id
Update id of a control in a page under contenttemplate from a custom user control?
我的共享点页面中有一个控件
<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
<SharePointWebControls:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<asp:Literal runat="server" id="Literal1" text="" visible="false"></asp:Literal>
i am trying to access this literal1 from a usercontrol and change the text value of this control or change the ID value of this control.
我尝试过更新DIV控件的id,但没有成功。这是用户控件的一部分。
HtmlGenericControl control = (System.Web.UI.HtmlControls.HtmlGenericControl)this.Page.FindControl("literal");
if (control != null)
{
control.Attributes.Clear();
control.Attributes.Add(ID,divid);
//control.Text = divid.ToString();
//document.getElementById('var_div').setAttribute('id',val)
}
任何人都知道它将如何工作
文本被渲染为零。请尝试使用Label。
相关文章:
- 如何从c#代码中获取asp控件id
- 将html控件id从aspx文件传递给javascript
- 将控件Id更改为变量
- 将 .net 按钮控件 ID 传递给 JavaScript 函数
- 通过jQuery查找控件ID,并将其传递给函数以切换它
- 将 ASP.Net 控件 ID 发送到 JavaScript 函数
- 如何访问位于同一文件中 js 中的数据列表中的控件 ID
- 查找 aspx 页和相应的 ascx 用户控件中存在的所有控件和子控件 ID
- 如何使用 java 脚本查找 asp 控件 ID
- 如何在另一个用户控件 ID 中获取用户控件 ID
- 将 GridView 控件 ID 传递给 JavaScript
- 在.js文件中获取.aspx控件ID
- 在外部javascript文件中获取asp控件ID的最佳方式是什么
- 如何使用javascript在用户控件页的父页中获取隐藏控件id
- 如何在克隆行的同时管理表行关联的javascript(控件ID)
- 与控件ID关联的访问服务器控件
- 如何在doPostBack中传递控件id
- 将客户端控件ID和值附加到请求对象…可能
- 如何在ASP.net中为可以使用控件ID调用的用户控件添加JavaScript函数
- 在ASP.net Listview中获取多个控件id的值并将其传递给JavaScript