473,320 Members | 2,071 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.

Includes and variables in .Net?!?

I am working on a site that requires a peice of code to be on every page in a site. This code however requires that a variable is passed from the page to the code that is on every page.

In ASP you could use #Includes with variables declared above it ad used inside it.

I think I have conquered the include bit by creating a Custom User Control with the necessary functionality, which can then be "Included" on every page. My problem however is that I now need to pass a variable to the page. I can pick up QueryStrings from the page, but I do not want the variables to be publicly visible.

Steps I have tried to date:
1.. Create properties on the pages and try to read them from the included user control. This solutions can not work, since I would have to create the parent object. This means that I need to know its name, but the control must be usable from any pages. Me.parent.... I think must provide a way to do that, but I do not know how.
2.. Create properties on the control and set them from the page. This works, except that the properties are set only after the page is loaded. I need to possibly redirect or stop the rendering of the page, should the variable be incorrect. (I stuck the code into the page_onload event.)
Any suggestions would be greatly appreciated.

Thanks
David Taylor
Nov 20 '05 #1
1 1017
Hi David,

I haven't explored this deeply.

How about declaring an Interface for your Pages which defines a method
that your UC can call from its constructor. This would happen pretty early on
in the Page's life, but I'm not sure if it will be early enough.

Public Sub New
DirectCast (UC.Parent, IWhatever).TheCallback (SomeValue)

Just a thought.

Regards,
Fergus
Nov 20 '05 #2

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

Similar topics

13
by: Tim Tyler | last post by:
A fairly simple question: I have a library A which depends on library B and C. Currently I have: <?php include("A.inc.php"); include("B.inc.php"); include("C.inc.php");
0
by: news | last post by:
Two questions actually, I hope I can get some advice from people who've used Zend Development Studio 4. 1. When I "analyze code", any variable that was defined in an included file and then used...
2
by: Joe Mowry | last post by:
First off, I'm posting this question for a friend that doesn't have access to the news groups. Problem: Using PHP as the base and has several PHP < includes > for various functions, all this...
4
by: Gary Contois | last post by:
I have seen the discussion below of how to use dynamic includes to get the info into the page. This is very helpful but does not quite fit my issue. I am currently using an include to pull in a...
10
by: Greg | last post by:
I'm trying to simulate server-side includes on the client-side by using JavaScript. My main problem is this: is there a way to somehow pass a variable into a directive like this: <SCRIPT...
7
by: MyndPhlyp | last post by:
I am building up a library of Class'es that represent various columns of table layouts. One often used column is "name" and each occurrence is treated identically. (What a concept, eh?) Part of...
10
by: Ben Taylor | last post by:
Hi, Coming from VB, I've still not really grasped the way how in C++ if function A wants to call function B, then function B has to be before function A in the compilation, and #includes that use...
4
by: Ron | last post by:
Hi all, Trying to work out a few problems in using php on my site. Partially this is a html question. I was reading a lot of the posts and it seems that some of the includes people are using are...
6
by: JRough | last post by:
I hate to ask an obvious question but I'm trying not to mess up anything worse than it is already. I have all these variables in- line. Can I do an include and take them off the file into an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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...
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
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.