开发者

webcontrols are all null when page is accessed after a redirect

开发者 https://www.devze.com 2023-04-13 05:34 出处:网络
I\'ve got the following situation. I\'ve created an asp.net website in visual studio 2008. In the root of the website I\'ve got one masterpage and one page old.aspx. I\'ve also got a folder contentpag

I've got the following situation. I've created an asp.net website in visual studio 2008. In the root of the website I've got one masterpage and one page old.aspx. I've also got a folder contentpages with a page called new.aspx. On the new.aspx I've got several web controls. One of them is a dropdown list which gets its datasource in the pageload event. This works perfectly when I visit this pays directly by typing the correct URL. old.aspx on the other hand is obsolete and should redirect to new.aspx. That's all what old.aspx does these days. However the pageload gets called from new.aspx and all of a sudden开发者_Python百科 it doesn't recognize any of the webcontrols. They're all NULL. How can I fix this?


Something else is going on here. Response.Redirect does exactly the same thing as typing in a URL in the address bar. It will load the page normally without any postback events. I am 100% sure on this. Server.Tranfer works slightly differently.

Shot in the dark: Did you by chance copy the file "old.aspx" and paste it in and change the name? Check your "Inherits" attribute on the @Page tag in the markup of new.aspx and make sure it matches the class name in the code behind, as well as the "CodeBehind" attribute. These can get out of whack if you copy files around manually, as its perfectly legal to have a markup page point to a different code behind or class, but it might not be what you intended.


you will have to find the controls explicitly. Try something like FindControls

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号