.NETGURU
Passing variables from ASPX to ASCX
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngreuse' list.


Dot Net Guruhew Killick
I have a web form which contains a user control. I need to be able to
set a variable value in the web form and read it from the user control.
I’m using VB.NET.

How should I do this? It seems one can’t just read the variables set by
the other.

Many thanks,
Dot Net Guru
Reply to this message...
 
    
Daniel Naumann
I have a web form which contains a user control. I need to be able to
set a variable value in the web form and read it from the user control.
I’m using VB.NET.

How should I do this? It seems one can’t just read the variables set by
the other.

Many thanks,
Dot Net Guru
Reply to this message...
 
    
M Killick
Thanks for the reply. I haven't used the Set command before.

Do you mean that if I *Set* a value in the parent page I can read the value
in the user control normally?

Is this code correct?

Set(ByVal Value As String)

concertids = Value

End Set

Thanks,
Dot Net Guru

"Daniel Naumann" <Click here to reveal e-mail address> wrote in message
news:673183@aspngreuse...
[Original message clipped]

Reply to this message...
 
    
Trevor Pinkney
Hi,

Here is some quick syntax.

its something like this (from within the usercontrol)

C#
System.Web.UI.Page CallingPage;
CallingPage = (System.Web.UI.Page)this.Page

but at work we have every Page derive from a basepage, so we go

OurProjectName.BasePage CallingPage;
CallingPage = (OurProjectName.BasePage)this.Page

CallingPage.WhateverMethod(); //Whatever method found on the base page.

You may want to use an interface in your case... I'm not sure if VB
supports those. but... C# it would be something like

public interface myInterface
{
public void FillTextBox(string text);
}

-------------

Then your page implement the interface

public class yourpagewithusercontrol : myInterface
{
public void FillTextBox(string text)
{
someTextBox.Text=text;
}
}

then in your user control you go

myInterface m;
m = (myInterface)this.Page;
m.FillTextBox(somevalue);

I really should be providing some code examples but I'm just heading out
the door for work!

Let me know if you need a better explanation.

-Trevor

At 11:50 AM 6/21/2002 +0100, you wrote:
[Original message clipped]

Reply to this message...
 
    
M Killick
Thanks for the help. I've got that working now.

Cheers,
Dot Net Guru
"Trevor Pinkney" <Click here to reveal e-mail address> wrote in message news:673488@aspngreuse...
Hi,

Here is some quick syntax.

its something like this (from within the usercontrol)

C#
System.Web.UI.Page CallingPage;
CallingPage = (System.Web.UI.Page)this.Page

but at work we have every Page derive from a basepage, so we go

OurProjectName.BasePage CallingPage;
CallingPage = (OurProjectName.BasePage)this.Page

CallingPage.WhateverMethod(); //Whatever method found on the base page.

You may want to use an interface in your case... I'm not sure if VB supports those. but... C# it would be something like

public interface myInterface
{
public void FillTextBox(string text);
}

-------------

Then your page implement the interface

public class yourpagewithusercontrol : myInterface
{
public void FillTextBox(string text)
{
someTextBox.Text=text;
}
}

then in your user control you go

myInterface m;
m = (myInterface)this.Page;
m.FillTextBox(somevalue);

I really should be providing some code examples but I'm just heading out the door for work!

Let me know if you need a better explanation.

-Trevor

At 11:50 AM 6/21/2002 +0100, you wrote:

Thanks for the reply. I haven't used the Set command before.

Do you mean that if I *Set* a value in the parent page I can read the value
in the user control normally?

Is this code correct?

Set(ByVal Value As String)

concertids = Value

End Set

Thanks,
Dot Net Guru

"Daniel Naumann" <Click here to reveal e-mail address> wrote in message
news:673183@aspngreuse...
[Original message clipped]

| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT
</BODY>
[Original message clipped]

Reply to this message...
 
 
System.Web.UI.Page




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