Click here to Skip to main content
15,942,804 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
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
Posted

 
Share this answer
 
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
C#
protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = "HTTP POST Value: " + Request.Form["users1$TextBox1"].ToString();
        }


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
 
Share this answer
 
 
Share this answer
 
Visit:
http://www.c-sharpcorner.com/UploadFile/Santhi.M/PassingValuesfrmUCtoASPX11212005050040AM/PassingValuesfrmUCtoASPX.aspx[^]
http://codes.codedigest.com/CodeDigest/22-Passing-value-from-Page-to-UserControl-in-ASP-Net.aspx[^]
you must be looking for this.

Try This
In your user control expose a property for the value
VB
Public Property SomeValue() As String
Get
    Return textbox1.Text
End Get
End Property

Then in your aspx page load, just reference the user control's value.

VB
userControl1.SomeValue
 
Share this answer
 
v4
Comments
SnvMohan 9-Jan-14 4:32am    
I need to pass values from usercontrol to another page...and that page doesnt use userconrol..how to pass values...? your suggestion pages get values from same page where usercontrols used and values accessed directly....
Gitanjali Singh 9-Jan-14 4:44am    
check the updated solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900