[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

Mulitple Page_Load() ???

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
sal-ee
Asked:
sal-ee
  • 3
  • 2
1 Solution
 
Tristan ShortlandCommented:
Do:

void Page_Load() {
     doThing1;
     doThing2;
}

void doThing1(){
    'do stuff
}

void doThing1(){
    'do stuff
}

0
 
sal-eeAuthor Commented:
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
 
Tristan ShortlandCommented:
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
 
sal-eeAuthor Commented:
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
 
sal-eeAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now