将文本框值从一个表单传递到另一个表单 [英] Pass A textbox value from one form to another from

查看:113
本文介绍了将文本框值从一个表单传递到另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的程序员





i有两种形式form1和form2,form1包含两个文本框和按钮,在应用程序开始时form1将打开并且我将在单击按钮时在文本框中输入一些数字值,form2将打开,在form2的表单加载事件上我希望变量中的文本框值

解决方案

下面链接指向一篇文章,它会让你仔细看看很多技巧



在表单之间传递数据 [ ^ ]



问候..:)


创建一个名为something的类文件像Global一样,并在该类文件上分配一个静态变量。使用该静态变量保存值并检索值。



Ex。



私有静态strUSerid;



Global.strUserid = value;


你可以使用QueryString或Sessions来处理这个问题,



在查询字符串中传递textvalue

 Response.Redirect(  WebForm1.aspx?Name = + txtbox1.Text); 





并且要获得查询字符串值,您可以像这样使用

  if (Request.QueryString [< span class =code-string> 名称]!=  null 
string txtValue = Request.QueryString [ 名称];


Dear Programmers


i have two forms form1 and form2 ,form1 contain two textboxes and button ,at start of application form1 will open and i will enetr some numbers value in textboxes on click of the button, form2 will open , on form load event of form2 i want that textboxes value in variables

解决方案

Below link points to an article which will give you closer look at many techniques

Passing Data Between Forms[^]

Regards..:)


Create a Class file named something like Global and assign a static variable on that class file. Use that static variable to save the value and retrieve the value.

For Ex.

Private static strUSerid;

Global.strUserid = value;


You can use QueryString or Sessions to handle this,

Pass the textvalue in Query string

Response.Redirect("WebForm1.aspx?Name="+txtbox1.Text);



And to get the querystring value you can use like this

if (Request.QueryString["Name"]!= null)
    string txtValue = Request.QueryString["Name"];


这篇关于将文本框值从一个表单传递到另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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