0

I have a user control on a web page . I want to use the values of the web page on my web user control.How can i do this

2 Answers 2

1

If you are talking of using page values in code i-e on server side , then you can access the page properties by casting the "this.Ownerpage" property of user control , and if you are talking of it on client side , then using Javascript/Jquery in combination with hidden fields you can do it easily.

Sign up to request clarification or add additional context in comments.

Comments

1

You can create and set property in your user control:

private string m_name = string.Empty;
public string UserName()
{
    return TextBox.Text;
}

Then in your ASP.NET page you can access this property by:

MyUserControl.UserName();

3 Comments

+1 This is more clean and will let you avoid using the keyword "this"
@sumit: Adjust the code. The word after return ("TextBox") has to match the ID of your TextBox
What is the purpose for using m_name ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.