是ctl00在ASP NET恒定? [英] Is ctl00 a constant in ASP NET?

查看:234
本文介绍了是ctl00在ASP NET恒定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在与使用母版页生成的我的web应用程序来参一控。在HTML控件的名称将成为像这样ctl00 $ $日程地址搜索Maincontent ListBox1的。我可以放心地做在code?

I need to reference a control in my web app that was generated with the use of a master page. The name of the control in the HTML becomes something like this "ctl00$MainContent$ListBox1". Can I safely do this in the code?

string strName = "ctl00$MainContent$ListBox1";
if (Request.Form[strName] != null)
{
String selectedLanguage = Request.Form[strName];
}

PS。我不能使用ClientID属性,因为这code从InitializeCulture称为()重写。

PS. I cannot use ClientID property because this code is called from InitializeCulture() override.

推荐答案

您可以,但我做的是设置母版ID在我的的init()

You could, but what I do is set the MasterPage ID in my Init():

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"; 
}

这篇关于是ctl00在ASP NET恒定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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