如何在静态方法中获取文本框值 [英] how to get textbox value inside static method
本文介绍了如何在静态方法中获取文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在aspx.cs页面上有以下方法..我想在binddatatable()方法中访问文本框值。但它不在里面
I have following method on aspx.cs page.. I want to access textbox value inside binddatatable() method. but it is not available inside
[WebMethod]
public static UserDetails[] BindDatatable()
{
//Page page = HttpContext.Current.Handler as Page;
//TextBox txtBegin = (TextBox)page.FindControl("txtEmail");
//string s = txtBegin.Text;
DataTable dt = new DataTable();
List<userdetails> details = new List<userdetails>();
string sSql = "EXECUTE dbo.admin_user_sp_update @in_type = 2";
dt = EasyDBPoolcl.GetDataTable(sSql);
foreach (DataRow dtrow in dt.Rows)
{
UserDetails user = new UserDetails();
user.Email = dtrow["flag"].ToString();
details.Add(user);
}
return details.ToArray();
}
public class UserDetails
{
public string UserId { get; set; }
public string UserName { get; set; }
public string Location { get; set; }
public string Email { get; set; }
}
推荐答案
您是否可以使用文本框值作为查询字符串在网址中传递?
var textBoxValue =
Cant you use the textbox value to pass as a query string in the url?
var textBoxValue =
(#textboxId)。val(); //或document.getElementbyId(textboxId)。value();
url:.. / user / register.aspx / BundDatatable / someId?= + textBoxValue;
---
您必须将静态方法的签名更改为取这个参数:
public static UserDetails [] BindDatatable(string someId)
{...}
("#textboxId").val(); //or document.getElementbyId("textboxId").value();
url: "../user/register.aspx/BindDatatable/someId?=" + textBoxValue;
---
you will have to change the signature of the static method to take this parameter:
public static UserDetails[] BindDatatable(string someId)
{...}
>
http:// forums.asp.net/t/1871714.aspx [ ^ ]
这篇关于如何在静态方法中获取文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文