ASP.NET中的用户控件 [英] user control in ASP.NET

查看:116
本文介绍了ASP.NET中的用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经在ASP.NET中创建了一个包含Label&DropdownList的用户控件.我想在控件完全加载后获得dropdownlist的选定值.
任何人请帮助我.


提前致谢...

Hi,
I had created a user control in ASP.NET Which Contains a Label & DropdownList. I want to get the selected value of dropdownlist after the control is completelly loaded.
Anyone Plz Help me.


Thanks In Advance...

推荐答案

在用户控件内创建一个属性,就像这样

Create A property inside your User Control Like this

public string mySelectedValue
{
  get
  {
     return ddlControl1.SelectedValue.toString();
  }
}



在您使用UserControl的页面中访问属性,例如



access the property in your page where you are using the UserControl like

string strValue = UserControl1.mySelectedValue;



如果要访问客户端(在Javascript/jQuery内部)的控件,请执行以下操作



If you want to access the control at Client end (inside Javascript/jQuery), do the following

protected void Page_Load(object sender, EventArgs e)
{
    ClientScript.RegisterStartupScript("strCtrlID","'" + ddlCtrl.ClientID + "'");
    //Rest of your page load logic.
}





document.getElementById(strCtrlID); 



cheaars:)



cheaars :)


这篇关于ASP.NET中的用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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