473,568 Members | 2,962 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with ASCX Issue!

I have a web project that currently has a standard header, footer, and
menu ascx files. I am now suppose to change the project to allow a
user to choose from 3 different views, ie 3 different groups of those
.ascx files. Does anyone have some sample code on how to do this?
This needs to check once a user has signed in on which version to
display.

Thanks,
Wade

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 1295
> I have a web project that currently has a standard header, footer, and
menu ascx files. I am now suppose to change the project to allow a
user to choose from 3 different views, ie 3 different groups of those
ascx files. Does anyone have some sample code on how to do this?
This needs to check once a user has signed in on which version to
display.


I'm no expert, but I did something similiar for a screen version vs. a
'print friendly' version.

What I did is put the options inside the individual controls. ie, the page
links to the same header and footer, but depending on a querystring, these
two ASCX files return different HTML.

With judicious use of CSS (taking a lot of the styling out of the app) this
might be a solution for you.

-Darrel
Nov 18 '05 #2
"Wade Beasley" <wa**********@i nsightbb.com> wrote in message
news:eL******** ********@TK2MSF TNGP09.phx.gbl. ..
I have a web project that currently has a standard header, footer, and
menu ascx files. I am now suppose to change the project to allow a
user to choose from 3 different views, ie 3 different groups of those
ascx files. Does anyone have some sample code on how to do this?
This needs to check once a user has signed in on which version to
display.


You can use LoadControl to load the proper version of the .ascx file. The
following example is ripped off from Microsoft, then modified a bit:

private string whichView;

// When this page is loaded, it uses the TemplateControl .LoadControl
// method to programmaticall y create a user control. The user control
// is contained in the .ascx file that is passed as a parameter
// in the LoadControl call. The page then adds the control to its
// ControlCollecti on.
void Page_Load(objec t sender, System.EventArg s e)
{
// Obtain the UserControl object MyHeader from the
// user control file MyHeader_*.ascx .
if (!User.IsAuthen ticated)
whichView = "default";

Control myHeader= LoadControl(whi chView + "_MyHeader.ascx ");
Controls.Add(my Header);
}

You might then have default_MyHeade r.ascx, wide_MyHeader.a scx, and
green_MyHeader. ascx, depending on the value of whichView. You could do the
same with your footer and menu files.
--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #3

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

Similar topics

0
1094
by: Dan Nigro | last post by:
I am trying not to use frames in asp.net but this is my problem. I have an image viewer I am trying to developed. The top portion is the (next, previous page, zoom etc). The left side is and the rest is the . I did this same thing in asp with frames no problem. To learn something I am trying to do it with webontrols. I have 3 controls...
1
2867
by: Andrew Parsons | last post by:
Hi all, I had a weird issue with trying to use a cookie in a ASCX housed on my web forms and I was wondering if I am missing something. I wanted to use the authenticated cookie for the user name logged into the web site to show the user that they are logged on. If I do it in the main page (the ASPX that houses the ASCX) load event it...
2
3015
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The...
1
1763
by: Jouni Heikniemi | last post by:
Hi, This has been asked before, in <http://groups.google.fi/groups? selm=ureiu7b04kv839%40corp.supernews.com> for example; however, I haven't found any real answers, so I'll post this with some new data. I've encountered strange behavior with .ascx control files. If I have two controls with the same name (obviously residing in different...
10
2829
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I have to add a datalist control. Using this datalist control I should be able to add edit, modify and cancel the items listed in this control. ...
5
1794
by: Marc Violette | last post by:
<Reply-To: veejunk@sympatico.ca> Hello, I'm hoping someone can help me out here... I'm a beginner ASP.NET developper, and am trying to follow a series of exercises in the book entitled "Microsoft ASP.NET Step By Step" by Microsoft Press. When I try to display *any* ASP.NET page with a Sub() somewhere, I get the following error:
0
1408
by: Tonix | last post by:
This problem was originated by Thanh Nguyen. Your help is appreciated. Thanks. The original text is: Hi everyone, I'm encountering a very weird problem, I have spent the last 3 days trying to figure out how to fix but there is still no clue. Here is the problem: I define 2 WebUserControls:
3
2225
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for some reason I keep getting the error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
11
2118
by: Brad Baker | last post by:
I'm building a small web application - I started out placing all my code in one file (config.aspx). As I continue to add code though it was becoming very unwieldy. After doing some searching online I found an article which suggested I might place some of the code into web user controls. I created two new files (general_info.ascx and...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.