473,320 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I'm still lost how to have a control send a value back to a page.

UJ
I've got a user control with a drop down list of stuff. I want to have it so
that when the user changes the value in the list, it will show up in a label
on the main portion of the page. I can't figure out how to do it correctly.
I've tried setting a session variable when the drop down list changes but
the setting of the session variables seems to happen after the page_load
event has already happened.

Can anybody please help me?

All I want is the user object to change selected values and be able to
change a label on the main page to reflect that change......

TIA - Jeffrey.
Nov 19 '05 #1
4 1188
This is how I would go about this:

(1) Create a public property on your user control ie: private string
selectedText = ""; public string SelectedText{ get{return this.selectedText;
} }
(2) In the selected index changed event method on the drop down set that
property as desired;

(3) Wire up a PreRender event on this host page which does this.myLabel.Text
= this.myControl.SelectedText;

That should be all you need, hope that helps.

"UJ" wrote:
I've got a user control with a drop down list of stuff. I want to have it so
that when the user changes the value in the list, it will show up in a label
on the main portion of the page. I can't figure out how to do it correctly.
I've tried setting a session variable when the drop down list changes but
the setting of the session variables seems to happen after the page_load
event has already happened.

Can anybody please help me?

All I want is the user object to change selected values and be able to
change a label on the main page to reflect that change......

TIA - Jeffrey.

Nov 19 '05 #2
I've seen other techniques that are more 'correct' as far as
object-oriented principle are concerned, but I've used something like
this:

In my control I define a variable as the same type as the page (assume
it's MainPage.aspx):
Protected myParentPage As MainPage

Then in the code I can access the public properties and functions of
MainPage:

myParentPage.SetLabel(myText)

Nov 19 '05 #3
UJ
I tried doing it in preRender - but the object hasn't been defined yet.....

Any more suggestions?

"Jason L Lind" <Ja********@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
This is how I would go about this:

(1) Create a public property on your user control ie: private string
selectedText = ""; public string SelectedText{ get{return
this.selectedText;
} }
(2) In the selected index changed event method on the drop down set that
property as desired;

(3) Wire up a PreRender event on this host page which does
this.myLabel.Text
= this.myControl.SelectedText;

That should be all you need, hope that helps.

"UJ" wrote:
I've got a user control with a drop down list of stuff. I want to have it
so
that when the user changes the value in the list, it will show up in a
label
on the main portion of the page. I can't figure out how to do it
correctly.
I've tried setting a session variable when the drop down list changes but
the setting of the session variables seems to happen after the page_load
event has already happened.

Can anybody please help me?

All I want is the user object to change selected values and be able to
change a label on the main page to reflect that change......

TIA - Jeffrey.

Nov 19 '05 #4
UJ
Let me clarify - in the debugger, the value in prerender of my user control
is still set to nothing meaning the variable hasn't been defined yet.

"UJ" <fr**@nowhere.com> wrote in message
news:e2**************@TK2MSFTNGP14.phx.gbl...
I tried doing it in preRender - but the object hasn't been defined yet.....

Any more suggestions?

"Jason L Lind" <Ja********@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
This is how I would go about this:

(1) Create a public property on your user control ie: private string
selectedText = ""; public string SelectedText{ get{return
this.selectedText;
} }
(2) In the selected index changed event method on the drop down set that
property as desired;

(3) Wire up a PreRender event on this host page which does
this.myLabel.Text
= this.myControl.SelectedText;

That should be all you need, hope that helps.

"UJ" wrote:
I've got a user control with a drop down list of stuff. I want to have
it so
that when the user changes the value in the list, it will show up in a
label
on the main portion of the page. I can't figure out how to do it
correctly.
I've tried setting a session variable when the drop down list changes
but
the setting of the session variables seems to happen after the page_load
event has already happened.

Can anybody please help me?

All I want is the user object to change selected values and be able to
change a label on the main page to reflect that change......

TIA - Jeffrey.


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
3
by: Ed Chiu | last post by:
Hi, I plan to use panel to store multiple HTML text in a web form page, here is the code snippet that add HTML into panel: Dim lit1 As New Literal lit1.Text = strHTML...
2
by: summer00 | last post by:
Hi everyone, I found that the value of a variable(string type for example) is lost after the aspx page postback. E.G: private void Page_Load(object sender, System.EventArgs e) {
3
by: catweezle2010 | last post by:
Hello NG, I have three files (default.aspx, search.aspx and work.aspx). The way is: login on default (if session is newsession). The loginname I write into as sessionvariable (username). So I...
2
by: John Smith | last post by:
I am trying to use the menu control for a tabbed menu system but it's frustrating the hell out of me. The full code is listed below. The trouble that I'm having is that, when the user clicks on a...
2
by: pallaw | last post by:
Hello All, My web Client is using a COM component with connection point enabled.my client is getting call back from this component.now I have to update a text control in handler of this...
7
by: Andy B | last post by:
I have a class I am creating for data access. I need to access controls from inside the class that are on a particular page. How do I do this? or is creating an instance of the page class and using...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.