.NETGURU
user control interaction
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngfreeforall' list.


Ahmed, Salman
Here is my setup:

index.aspx has 2 user controls on the page.

UserControl#1

Has a dropdownlist

UserControl#2

Is suppose to visible only when the user selects a value from the
dropdownlist(uc#1) and clicks the button.

How can I check for a value or post back from user control one for the
dropdownlist?
Reply to this message...
 
    
Dot Net Guru Serdar
in UC1

'create a publicly accessible event for other pages to see, this event will
be raised when the combo is changed
Public Event UC1_Combo_Changed(ByVal sender As Object, ByVal e As
System.EventArgs)

'this is the event for your combo box
Private Sub Uc1_Combo_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Uc1_Combo_.SelectedIndexChanged
RaiseEvent UC1_Combo_Changed(sender, e)
End Sub

'now in your 'parent' page that has the 2 user controls
'you'll have your usercontrol protected event
Protected WithEvents myUC1 As UC1

'if you select from the 2 combo boxes at the top of your IDE's code behind
window you'll find that UC1_Combo_Changed or whatever you named your public
event will appear in the left combo box and then in the 'Declarations' combo
on the right you'll find the public event UC1_Combo_Changed. If you select
these .NET will automatically stub out your private sub to roughly resemble
this
Private Sub UC1_Combo_Changed(ByVal sender As Object, ByVal e As UC1)
Handles Uc1_Combo_.SelectedIndexChanged

End Sub

hth
matt

-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 6:33 AM
To: aspngfreeforall
Subject: [aspngfreeforall] user control interaction

Here is my setup:

index.aspx has 2 user controls on the page.

UserControl#1

Has a dropdownlist

UserControl#2

Is suppose to visible only when the user selects a value from the
dropdownlist(uc#1) and clicks the button.

How can I check for a value or post back from user control one for the
dropdownlist?

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/aspngfreeforall JOIN/QUIT | news://ls.asplists.com = NEWSGROUP
Reply to this message...
 
    
Moores, Ian
As far as i am aware there is no way to automatically transfer data from
one usercontrol to another... if there is then i please let me know as
well .. i am doing it using out-of-process session variables....

Ian Moores

Web Developer / WebMaster

iRevolution Ltd

+44 (0)1895 425 789 Direct

+44 (0)1895 444 420 Tel

+44 (0)1895 444 460 Fax

    -----Original Message-----
    From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
    Sent: 06 August 2002 14:33
    To: aspngfreeforall
    Subject: [aspngfreeforall] user control interaction



    Here is my setup:

    

    index.aspx has 2 user controls on the page.

    

    UserControl#1

    Has a dropdownlist

    

    UserControl#2

    Is suppose to visible only when the user selects a value from
the dropdownlist(uc#1) and clicks the button.

    

    

    How can I check for a value or post back from user control one
for the dropdownlist?

    | ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall]
member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT |
news://ls.asplists.com = NEWSGROUP
Reply to this message...
 
    
Ahmed, Salman
One method would be to add the selected item in the httpcontext.items and
then access it from the other user control. Just wanted to get other
peoples thoughts on the topic, there doesn't seem to a 'industry' standard
way of doing this even though I would suspect it is a comment problem.

-----Original Message-----
From: Moores, Ian [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 11:18 AM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: user control interaction

As far as i am aware there is no way to automatically transfer data from one
usercontrol to another... if there is then i please let me know as well .. i
am doing it using out-of-process session variables....

Ian Moores

Web Developer / WebMaster

iRevolution Ltd

+44 (0)1895 425 789 Direct

+44 (0)1895 444 420 Tel

+44 (0)1895 444 460 Fax

-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: 06 August 2002 14:33
To: aspngfreeforall
Subject: [aspngfreeforall] user control interaction

Here is my setup:

index.aspx has 2 user controls on the page.

UserControl#1

Has a dropdownlist

UserControl#2

Is suppose to visible only when the user selects a value from the
dropdownlist(uc#1) and clicks the button.

How can I check for a value or post back from user control one for the
dropdownlist?

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP
Reply to this message...
 
    
Feduke Cntr Charles R
You could mark your controls as serializable and then have a method or
constructor in another control that consumes the serial stream of another
user control to share data between the controls.

Of course I don't think the above has anything to do with the question
that was asked. You probably want to take a look at the
OnSelectIndexChanged event (make sure ViewState for the DropDownList is
enabled for this event to fire!) with AutoPostBack = true (when AutoPostBack
is set to true on a DropDownList, the page will automatically post back to
the server when the DropDownList's contents are changed). Then in your
SelectIndexChanged event you'd just userControl2.Visible = true;. This
doesn't do anything for client-side script, but to do that just...

<asp:DropDownList onClick="document.<%= userControl2.UniqueID
%>.style.visible = 'visible';" />
<!-- might have to check on that JavaScript above, its from memory -->

assuming userControl2 is the Id of your second user control and its also
defined as a variable in your code behind file.

HTH,
- Chuck

-----Original Message-----
From: Moores, Ian [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 11:18 AM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: user control interaction

As far as i am aware there is no way to automatically transfer data from one
usercontrol to another... if there is then i please let me know as well .. i
am doing it using out-of-process session variables....

Ian Moores

Web Developer / WebMaster

iRevolution Ltd

+44 (0)1895 425 789 Direct

+44 (0)1895 444 420 Tel

+44 (0)1895 444 460 Fax

-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: 06 August 2002 14:33
To: aspngfreeforall
Subject: [aspngfreeforall] user control interaction

Here is my setup:

index.aspx has 2 user controls on the page.

UserControl#1

Has a dropdownlist

UserControl#2

Is suppose to visible only when the user selects a value from the
dropdownlist(uc#1) and clicks the button.

How can I check for a value or post back from user control one for the
dropdownlist?

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/aspngfreeforall JOIN/QUIT | news://ls.asplists.com = NEWSGROUP
Reply to this message...
 
    
Ahmed, Salman
I have a button that has a onclick event that checks for the value selected
in the listbox..do I have to reload the listbox with the values from the
database before doing this check?

I keep getting System.NullReferenceException: Object reference not set to an
instance of an object.??

My Code:

public void btnEditUser_Click(object sender, EventArgs e)

{

Response.Write (lbUsers.SelectedItem.Value);

}

-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 12:46 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: user control interaction

One method would be to add the selected item in the httpcontext.items and
then access it from the other user control. Just wanted to get other
peoples thoughts on the topic, there doesn't seem to a 'industry' standard
way of doing this even though I would suspect it is a comment problem.

-----Original Message-----
From: Moores, Ian [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 11:18 AM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: user control interaction

As far as i am aware there is no way to automatically transfer data from one
usercontrol to another... if there is then i please let me know as well .. i
am doing it using out-of-process session variables....

Ian Moores

Web Developer / WebMaster

iRevolution Ltd

+44 (0)1895 425 789 Direct

+44 (0)1895 444 420 Tel

+44 (0)1895 444 460 Fax

-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: 06 August 2002 14:33
To: aspngfreeforall
Subject: [aspngfreeforall] user control interaction

Here is my setup:

index.aspx has 2 user controls on the page.

UserControl#1

Has a dropdownlist

UserControl#2

Is suppose to visible only when the user selects a value from the
dropdownlist(uc#1) and clicks the button.

How can I check for a value or post back from user control one for the
dropdownlist?

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP
Reply to this message...
 
    
Thomas Fuller
Need to see more code to be sure. Is this code fired off on the postback?
Is there n item actually chosen. I'm working on something that uses these
list box values right now and your syntax looks fine below. I think the
problem is somewhere other than here.

Tom

-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 1:40 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: user control interaction

I have a button that has a onclick event that checks for the value selected
in the listbox..do I have to reload the listbox with the values from the
database before doing this check?

I keep getting System.NullReferenceException: Object reference not set to an
instance of an object.??

My Code:

public void btnEditUser_Click(object sender, EventArgs e)
{
Response.Write (lbUsers.SelectedItem.Value);
}

-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 12:46 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: user control interaction

One method would be to add the selected item in the httpcontext.items and
then access it from the other user control. Just wanted to get other
peoples thoughts on the topic, there doesn't seem to a 'industry' standard
way of doing this even though I would suspect it is a comment problem.

-----Original Message-----
From: Moores, Ian [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 06, 2002 11:18 AM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: user control interaction

As far as i am aware there is no way to automatically transfer data from one
usercontrol to another... if there is then i please let me know as well .. i
am doing it using out-of-process session variables....

Ian Moores
Web Developer / WebMaster
iRevolution Ltd
+44 (0)1895 425 789 Direct
+44 (0)1895 444 420 Tel
+44 (0)1895 444 460 Fax
-----Original Message-----
From: Ahmed, Salman [mailto:Click here to reveal e-mail address]
Sent: 06 August 2002 14:33
To: aspngfreeforall
Subject: [aspngfreeforall] user control interaction
Here is my setup:

index.aspx has 2 user controls on the page.

UserControl#1
Has a dropdownlist

UserControl#2
Is suppose to visible only when the user selects a value from the
dropdownlist(uc#1) and clicks the button.

How can I check for a value or post back from user control one for the
dropdownlist?
| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP
| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP
| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP
| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/aspngfreeforall JOIN/QUIT | news://ls.asplists.com = NEWSGROUP
Reply to this message...
 
 
System.EventArgs
System.NullReferenceException
System.Web.UI.UserControl
System.Web.UI.WebControls.DropDownList
System.Windows.Forms.UserControl




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification