如何获取用户控件的文本框值 [英] how to get textbox value of user control

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

问题描述

我使用Jquery在asp.net(包含3个文本框)中动态添加了用户控件,

如何在aspx.cs文件中获取用户控件的文本框值。



在aspx页面中动态显示用户控件页面后,当我点击我需要获取aspx.cs页面中textbox值的按钮时,我在aspx页面中有一个按钮

解决方案

最好的方法是为用户控件中的每个文本框创建一个属性:



  public   string  TextBox1Value 
{
< span class =code-keyword> get
{
return textbox1.text;
}
}



,您可以直接从您的页面进行操作:



 usercontrol1.TextBox1Value; 



这将包含文本框值。






创建文本框的属性,公开它们然后从调用页面访问。



希望对您有帮助。


System.Web.UI.WebControls.TextBox.Text 有什么问题?请参阅:

http:// msdn .microsoft.com / zh-cn / library / system.web.ui.webcontrols.textbox.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.text .aspx [ ^ ]。



-SA


I added the user control dynamically in asp.net(which contain 3 textboxes) using Jquery,
how to get textbox value of user control in aspx.cs file.

After dynamically show the user control page in aspx page, I have a button in aspx page when I click the button I need to get the value of textbox in aspx.cs page

解决方案

The best way to do that would be to create a property for each text box inside the user control as:

public string TextBox1Value
{
 get
 {
  return textbox1.text;
 }
}


and from your page you can directly do:

usercontrol1.TextBox1Value;


this will contain the textbox value.


Hi,

Create property of the textbox expose them and then access form the calling page.

Hope this help you.


What's wrong with System.Web.UI.WebControls.TextBox.Text? Please see:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.aspx[^],
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.text.aspx[^].

—SA


这篇关于如何获取用户控件的文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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