Solved

Mulitple Page_Load() ???

Posted on 2008-06-11
5
269 Views
Last Modified: 2010-04-06
Hello,

I have a dreamweaver template created in C# with a void Page_Load() procedure. I have another page that this template is applied to, but which also has a Page_Load() to do its own thing. I can't have two page_loads so how would you recommend I work around this?

They both need to check a value in a database before displaying the page, which is why they both have page_load events/procedures.
0
Comment
Question by:sal-ee
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Tristan Shortland
Comment Utility
Do:

void Page_Load() {
     doThing1;
     doThing2;
}

void doThing1(){
    'do stuff
}

void doThing1(){
    'do stuff
}

0
 
LVL 2

Author Comment

by:sal-ee
Comment Utility
So close!! Thing is, my template needs the page_load() in order to format the template for the right users (i.e. for Managers, they see a different template).

The other page needs to select a record from the database on page load too, in order to determine whether to display a form or not.

The template is applied to many other pages which will not contain "doThing2"... Am I making sense?
0
 
LVL 4

Expert Comment

by:Tristan Shortland
Comment Utility
Could you say :

try{
     doThing2;
} catch {
    'doesn't matter
}

So that it only calls do thing 2 if it exists, and just ignores it on other pages?
0
 
LVL 2

Author Comment

by:sal-ee
Comment Utility
Well, I don't know much about try and catch and I was looking around on the Internet. I tried just as you said above so I put (checkDisc() being my "doThing2")

try{
    checkDisc();
}catch{
    //do nothing
}

- literally! I don't know what I have to put in the //do nothing part? Could you help me with what to write, like literally the code? Sorry for being difficult!
0
 
LVL 2

Accepted Solution

by:
sal-ee earned 0 total points
Comment Utility
I looked into the try and catch statement but it didn't work when everything and everybody said it should do! So I gave up. I've had to do a dirty fix to get past this as the intranet I am building needed to go live. So I created a second template for that one page to have a different page_load from the others. So basically, I have one page with it's own template. Not good but it works for now!

So somebody, please help as I can't leave it like this!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now