将一个aspx页面的控件数据显示到另一个aspx页面。 [英] Showing data of a control of one aspx page to another aspx page.

查看:304
本文介绍了将一个aspx页面的控件数据显示到另一个aspx页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从 Default.aspx'的页面 textbox1值将显示在另一页 Default2.aspx 的标签中。为此,有一个按钮Default.aspx页面和按钮的单击事件我写了Response.Redirect(Default2.aspx)我在Default2.aspx按钮'的点击事件下写了下面的代码:



  protected   void  Button1_Click( object  sender,EventArgs e)
{

TextBox tb =(TextBox)PreviousPage.FindControl( TextBox1); if (tb!= null
{
Label1.Text = tb。文本;
}
}





出现错误。错误消息是:对象引用未设置为对象的实例请帮助我。

解决方案

http://msdn.microsoft.com/tr-tr/library/6c3yckfw(v = VS.100)的.aspx [ ^ ]



我认为你做错了。在本页底部,您可以找到自己的方式。我还建议你从公共场所获取价值。


你好,



请试试这个......



protected void Button1_Click(object sender,EventArgs e)

{



TextBox tb = (文本框)PreviousPage.FindControl(TextBox1中)文本。 if(tb!= null)

{

Label1.Text = tb.Text;

}

}


hii



所以想要default.aspx中textbox的值显示在default2.aspx的标签上? ?



在default.aspx上写这个

 //从文本框中存储值
protected void Button1_Click (object sender,EventArgs e)
{
Response.Redirect(default2.aspx?Name =+ txtName.Text);
}







在default2.aspx上写这个

 //调用值来标记
protected void Button1_Click(object sender,EventArgs e)
{
if(Request.QueryString [Name]!= null)
Label.Text = Request.QueryString [Name];
}





您可以在page_load()中编写第二个代码,即default2.aspx。它会自动将值扔进标签



它会工作:)



快乐编码


I want from the page of Default.aspx''s textbox1 value will show in a label of another page Default2.aspx.For this there is a button in Default.aspx page and in the click event of the button I wrote Response.Redirect("Default2.aspx") I have written the following codes under button''s click event in Default2.aspx :

protected void Button1_Click(object sender, EventArgs e)
    {
       
        TextBox tb = (TextBox)PreviousPage.FindControl("TextBox1"); if (tb != null)
        {
            Label1.Text = tb.Text;
        }
    }



It arises an error. The error message is : "Object reference not set to an instance of an object" Please help me.

解决方案

http://msdn.microsoft.com/tr-tr/library/6c3yckfw(v=vs.100).aspx[^]

I think you did somethign wrong. At the bottom of this page you can find your ways. Also I recommend you to get values from public properties.


Hi,

Please try this...

protected void Button1_Click(object sender, EventArgs e)
{

TextBox tb = (TextBox)PreviousPage.FindControl(TextBox1;).text; if (tb != null)
{
Label1.Text = tb.Text;
}
}


hii

so want that the value of textbox in default.aspx to be displayed in label of default2.aspx???

write this on default.aspx

//storing values from textbox
protected void Button1_Click(object sender, EventArgs e)
{
 Response.Redirect("default2.aspx?Name="+txtName.Text);
}




write this on default2.aspx

// calling values to label
protected void Button1_Click(object sender, EventArgs e)
{
if (Request.QueryString["Name"]!= null)
    Label.Text = Request.QueryString["Name"];
}



you can write the second code i.e. default2.aspx in page_load(). it will automatically throw values into the label

It will work :)

Happy coding


这篇关于将一个aspx页面的控件数据显示到另一个aspx页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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