I've been reading beginning asp.net 3.5 and following basic tutorials from this site and learnvisualstudio.net.
I don't think I've came across why you cannot create public variables inside page_load. I always have to declare public variables before the page_load block for them to work. The reason why I would like to use public variables inside other blocks is because I like data binding expressions into my .aspx page and it will only let me <%# varibleName %> expressions that are public. I'm sure there are better methods like creating Labels and setting text property equal to my private strings name but I end up with the <spans> that labels generate and Im a control freak, I like putting single type data expressions inside <p> or <h3> which makes it easier for me to manage my CSS file for the appearances of them. I guess the queston I would like answered mostly is why can't I declare public variables inside page_load.
View Complete Post