asp.net/vb - still lost

admin

Administrator
Staff member
Hi, I have been developing apps with asp 3 using vbscript for years. I am STILL having problems doing the simplest task using the .net stuff.

The setup is to have each content page of the app use the same headers, footers, nav, and base set of "functions". Currently, my main problem is trying to read anything from a included page into the current page. I have been playing with master pages, user controls etc. I am just not "getting" it. I have a special user authorization setup that needs to be ran on every page. That routine returns a set of variables that then needs to be available to the page for use, for even something as simple as displaying in the page or using in routines on the current page. I am not able to access any of that information.

Is asp I would have a page that was my auth routine, then include that page in every content page near the top. When the content page was ran, it would start with the auth, set what I need, and that information (strings written to the screen or variables) would be incorporated into the appropriate places of code in the asp.from what i understood, i think what you need is user control.
First create a page with extention ".ascx" and here's what you should add in the page top:

<%@ Control Language="VB" Debug="True" %>

and then you create your page so normaly without using "<HTML><HEAD></HEAD><BODY></BODY></HTML>" then in the page you want to add this control, you add it like this:

in the top: after <%@ Page %> Tag
<%@ Register TagPrefix="ASPUC" TagName="AuthUser" src=http://www.webdeveloper.com/forum/archive/index.php/"UC.ascx" %>

in Body (in the place you want to add):
<ASPUC:AuthUser runat="server" />do u use vs.net?
if so, on ur "Solution Exploer",
1) right click ur project namespace
2) mouse on "Add", and choose "Add Web User Control"
3) give a name to that control that will ended with "ascx"
4) put ur html tag, asp controls, web controls on ur ascx page like u normally would do with aspx.
5) when done, go back to the aspx page, drag the ascx page and drop your user control on your design form. vs.net will handle everything for you.OK, thank you for your replies. I have actually been trying the UC route, I found several articles abut using them and it seems a way to go. Now let me ask this. Lets say I have a couple functions in the user control. I want to be able to use one of the functions in the content page. How do I expose it and then use it in the code on the content page?setup delegate and event from UC and have ur aspx.vb page listen to the event from ur UC. Can pass value(s) through ascx to aspx.vb page using EventArgs e value.

personally speaking, based on the limited description you've provided, I'm guessing setup a componment object would better suit your need.You can make methods and properties in the user control public and then you can access them from the container page's code.

If there is no visual components to the includes then I'd use a static class instead of a user control. You could even put static data and methods in the Global.asax file and have it available in every form as methods and properties of the Global object.

For example, in Global.asax you write

public static mymethod()
{
return "hi";
}

then in your page code you can write

if(Global.mymethod() == "hi") ....
 
Back
Top