在Usercontrol和aspx页面之间传递值 [英] Pass the Values between Usercontrol and aspx pages

查看:85
本文介绍了在Usercontrol和aspx页面之间传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站中有一个(SearchEmployee.ascx)Usercontrol for Search Employee详细信息...我需要将此Usercontrol用于我的所有aspx页面..当用户在usercontrol上单击searchbutton时,页面必须重定向到searchpage。 aspx与enduser给出的值...我不想使用Session和Querystring传递值...然后我如何将值传递给searchpage.aspx ... Searchpage.aspx不包含此usercontrol ... In这个页面我从数据库中获取的细节取决于值.......请给我一个关于usercontrol和aspx页面之间传递值的建议

I have a (SearchEmployee.ascx) Usercontrol for Search Employee details in my site... I need to use this Usercontrol into all my aspx pages..when the user click searchbutton on usercontrol then page must be redirected to searchpage.aspx with the values given by enduser...i dont want to use Session and Querystring to pass values...Then How can i pass values to searchpage.aspx... Searchpage.aspx does't contain this usercontrol...In this page i have get the details from database depend on the values.......Please Give me a suggestions for pass values between usercontrol and aspx page

推荐答案

点击此链接 http://forums.asp.net/t/1377831.aspx [ ^ ]


这更像是移动页面到页面的数据。



由于您不需要使用查询字符串和会话,您可以通过POst方法传输数据



在ASP.NET中的页面之间传递值 [ ^ ]



对于从用户控制中获取日期的情况,请按照简单的示例进行操作。



在搜索页面中你必须使用以下

It is more like moving data from Page to Page.

Since you dont need to use Query string and Session, You can transfer the data by POst method

Passing Value Between Pages in ASP.NET[^]

For your case to get the date from user control just follow the simple example.

In the search page you have to use the following
protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = "HTTP POST Value: " + Request.Form["users1


TextBox1]。ToString();
}
TextBox1"].ToString(); }





其中users1是上一页的Search User控件的ID,TextBox1是Textbox的id在用户控件中。



在上面的代码中,请确保对所有具有搜索控制权的页面使用相同的ID



where users1 is the ID of the Search User control of the previous page and TextBox1 is the id of the Textbox in the user control .

Here in the above code make sure you use same id for all the pages that have search control


这篇关于在Usercontrol和aspx页面之间传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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