加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 在.NET .NET中ctl00是常量吗?

发布时间:2020-12-16 04:36:33 所属栏目:asp.Net 来源:网络整理
导读:我需要在我的Web应用程序中引用一个使用母版页生成的控件. HTML中控件的名称变为类似“ctl00 $MainContent $ListBox1”.我可以在代码中安全地执行此操作吗? string strName = "ctl00$MainContent$ListBox1";if (Request.Form[strName] != null){String sele
我需要在我的Web应用程序中引用一个使用母版页生成的控件. HTML中控件的名称变为类似“ctl00 $MainContent $ListBox1”.我可以在代码中安全地执行此操作吗?
string strName = "ctl00$MainContent$ListBox1";
if (Request.Form[strName] != null)
{
String selectedLanguage = Request.Form[strName];
}

PS.我不能使用ClientID属性,因为从InitializeCulture()覆盖调用此代码.

解决方法

你可以,但我做的是在我的Init()中设置MasterPage ID:
protected void Page_Init( object sender,EventArgs e ) 
{
    // this must be done in Page_Init or the controls 
    // will still use "ctl00_xxx",instead of "Mstr_xxx"
    this.ID = "Mstr"; 
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读