Multimobile Development: Building Applications for any Smartphone
Passing variables from ASPX to ASCX
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngreuse' list.


Matthew 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,
Matt
Reply to this message...
Vote that this is a GOOD answer...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
    
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,
Matt
Reply to this message...
Vote that this is a GOOD answer...
 
First volume of Multimobile Development nearly ready to go to press
A mention on Developing for the iPhone and Android: The pros and cons
 
    
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,
Matt

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

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
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...
Vote that this is a GOOD answer...
 
First chapters of Multimobile Development book now available on Apress Alpha program
iPad
 
    
M Killick
Thanks for the help. I've got that working now.

Cheers,
Matt
"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,
Matt

"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...
Vote that this is a GOOD answer...
 
New book project – Multimobile Development: Building Applications for any Smartphone
Dive into HTML5
 
 
System.Web.UI.Page




Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734