accessing textbox which is inside ascx file
-
hello i have a problem in accessing textbox from its usercontrol. i have textbox in the user control i.e in ascx file and now i want to use that textbox value in the aspx page. But I want to use it without using delegates and all. is there any simple way to access it like a regular textbox ??
suchita
Hi Suchita, Based on this flow of yours: 1. Fill some value in Usercontrol ascx: ValueA 2. Press buttonA in ASPX parent page. 3. buttonA, brings ValueA in the textboxA of ASPX parent page 4. buttonA, send the ValueA in DB to store. Try this:
//In UserControl.ascx.cs
public string txtBoxInUCExposed
{
get { return txtBoxInUserControl.Text;}
set { txtBoxInUserControl.Text = value} // as such you don't need a set based on your flow
}//In Parent.aspx
//When you drag drop the UC, you will have a UC tag in designer. Lets say you gave it an ID="myUC1"//In Parent.aspx.cs
//when buttonA clicks, in its event access it as:
string valueInUCTextBox = myUC1.txtBoxInUCExposed;
// Now use this value to insert it in the database. -
SayamiSuchi wrote:
if you can't do that, better say I can't
Don't get cocky. Look around, I think I've demonstrated ability well enough. Show what you have tried. Creating a property is very, very, very simple basic knowledge.
I know the language. I've read a book. - _Madmatt
also i am trying to use findcontrol property and its not working.. i dont know what parameter i'm missing.. my ascx page name is usercontrol.ascx and it has one textbox named textbox2. and my aspx page has one button named button1 and textbox named textbox1. now i am trying to show the value of textbox2 in textbox1 on button1 click event. protected void Button1_Click(object sender, EventArgs e) { usercontrol1 u = new usercontrol1(); string s = u.FindControl("Textbox2"); TextBox1.Text = u.ToString(); } This is not working. I doubt the way i used the textbox2 is wrong but i dont know where i'm wrong.
suchita
-
Hi Suchita, Based on this flow of yours: 1. Fill some value in Usercontrol ascx: ValueA 2. Press buttonA in ASPX parent page. 3. buttonA, brings ValueA in the textboxA of ASPX parent page 4. buttonA, send the ValueA in DB to store. Try this:
//In UserControl.ascx.cs
public string txtBoxInUCExposed
{
get { return txtBoxInUserControl.Text;}
set { txtBoxInUserControl.Text = value} // as such you don't need a set based on your flow
}//In Parent.aspx
//When you drag drop the UC, you will have a UC tag in designer. Lets say you gave it an ID="myUC1"//In Parent.aspx.cs
//when buttonA clicks, in its event access it as:
string valueInUCTextBox = myUC1.txtBoxInUCExposed;
// Now use this value to insert it in the database.My opinion. If the OP could not have figured out how to do this simple task then giving it to him like this did not help and just made hime dependent on others and a burden to his team, now and in the future.
I know the language. I've read a book. - _Madmatt
-
Hi Suchita, Based on this flow of yours: 1. Fill some value in Usercontrol ascx: ValueA 2. Press buttonA in ASPX parent page. 3. buttonA, brings ValueA in the textboxA of ASPX parent page 4. buttonA, send the ValueA in DB to store. Try this:
//In UserControl.ascx.cs
public string txtBoxInUCExposed
{
get { return txtBoxInUserControl.Text;}
set { txtBoxInUserControl.Text = value} // as such you don't need a set based on your flow
}//In Parent.aspx
//When you drag drop the UC, you will have a UC tag in designer. Lets say you gave it an ID="myUC1"//In Parent.aspx.cs
//when buttonA clicks, in its event access it as:
string valueInUCTextBox = myUC1.txtBoxInUCExposed;
// Now use this value to insert it in the database. -
My opinion. If the OP could not have figured out how to do this simple task then giving it to him like this did not help and just made hime dependent on others and a burden to his team, now and in the future.
I know the language. I've read a book. - _Madmatt
-
if i take your opinion, i wont be learning ..instead i will be more frustrating... how can one learn if the confusion I have wont get out of it. I need help for that and thats what this forum is about. Dont you think so ??
suchita
I've said it many times now. Creating a property is a very, very, simple basic task that you should have learned long ago. Every basic beginner book coveres it. Almost every code sample has one. If you can't figure it out, then quit, please.
I know the language. I've read a book. - _Madmatt
-
I've said it many times now. Creating a property is a very, very, simple basic task that you should have learned long ago. Every basic beginner book coveres it. Almost every code sample has one. If you can't figure it out, then quit, please.
I know the language. I've read a book. - _Madmatt
-
I've said it many times now. Creating a property is a very, very, simple basic task that you should have learned long ago. Every basic beginner book coveres it. Almost every code sample has one. If you can't figure it out, then quit, please.
I know the language. I've read a book. - _Madmatt
-
i am using dot net after 4 years.so i forgot and confuse. i am restarting it again and enjoying it too. What is your problem ? If you can't help, dont post please...
suchita
I don't care long it has been since you last used it. Read the response again, basic simeple task covered by many, many, many, many resources. If you can't do basic tasks, then please don't bother us
I know the language. I've read a book. - _Madmatt
-
Thank you to both of you..... Its a long time I didnt use dot net... So i forgot most of the part. that's the problem with me.. Slowly once again i am getting into it. thank you sandeep..
suchita
Hey what's up here? discuss your differences outside the forum ;) a property is very simple to learn! I have learned :laugh: have you searched in google?? I know nobody is perfect but when you have the opportunity to search something without posting, just search and don't mess with stressed people like us! ;) thanks :thumbsup:
-
My opinion. If the OP could not have figured out how to do this simple task then giving it to him like this did not help and just made hime dependent on others and a burden to his team, now and in the future.
I know the language. I've read a book. - _Madmatt
Mark Nischalke wrote:
My opinion.
Got that! But out here we find lots of people asking without trying! We keep on saying, try first, show your effort. I found this OP has put effort and tried. Might be some reason(which looks like low in confidence) why OP was unable to resolve it after pointing out the way... So, to me, it looked like instead of discouraging, we should provide OP with what he is looking for. From this, he can learn what was pointed out and what was he not able to search. This will add to OP's learning curve. Not everyone can have same pace and level of understanding. One should be provided some time and help to pace up!
-
Hey what's up here? discuss your differences outside the forum ;) a property is very simple to learn! I have learned :laugh: have you searched in google?? I know nobody is perfect but when you have the opportunity to search something without posting, just search and don't mess with stressed people like us! ;) thanks :thumbsup:
-
Mark Nischalke wrote:
My opinion.
Got that! But out here we find lots of people asking without trying! We keep on saying, try first, show your effort. I found this OP has put effort and tried. Might be some reason(which looks like low in confidence) why OP was unable to resolve it after pointing out the way... So, to me, it looked like instead of discouraging, we should provide OP with what he is looking for. From this, he can learn what was pointed out and what was he not able to search. This will add to OP's learning curve. Not everyone can have same pace and level of understanding. One should be provided some time and help to pace up!