Click here to Skip to main content
15,125,547 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if i had an aspx page and if i write pageload on aspx and also in aspx.cs..........which pageload one will be executed ,in aspx or in the code behind will be executed first and why?
Nicholas Marty 15-Nov-13 7:21am
I guess this should create a conflict as the resulting class will have two methods with the same definition...
spanner21 15-Nov-13 7:24am
ok..means will it result in any compiler error?
Nicholas Marty 15-Nov-13 7:27am
not necessarily as you're able to modify the page even after compilation. But quite surely when you're requesting the page.
spanner21 15-Nov-13 7:29am
ok...if the page is in webproect named pageconfflict.........i cant run the solution........right?

1 solution

You can only have one and they will execute the same. They end up getting compiled the same way. I prefer code in codebehind files but you don't have to.
Nicholas Marty 15-Nov-13 9:04am
I just tried it with a the ASP.Net Webapplication Default Template. Interesting thing is: Although there is a compiler warning that the Method on the ASPX page is hiding the one from Codebehind when running the page both methods were executed. (First the CodeBehind one, then the ASPX one) I would however strongly suggest to avoid such a thing as it causes more confusion than it's useful...
ZurdoDev 15-Nov-13 9:07am
Interesting. Good to know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900