Forum Moderators: open
This is going to be a long one so please bear with me.
I've built a site where Global.asax matches the url to my Sitemap and loads in the corresponding .aspx page accordingly.
So: blog/blogcommentform.aspx loads in managed_content/pages/28/page28.aspx
There's a long explanation for this but it's basically so we can use our existing content management tool.
(The long explanation: http://www.webmasterworld.com/microsoft_asp_net/3935014.htm [webmasterworld.com])
My problem occurs when I have a form on the page. If the form is submited using a submit button, there isn't a problem (I've set the preserveForm value to "true"), but when I try and submit the data through a button click it just won't work.
protected void CommentSubmit_Click(object sender, EventArgs e)
{
Response.Write("BUTTON CLICKED");
}
displays nothing.
I've built and tested the form outside of my main project so am confident that the problem's not in the form, but is caused by the server.transfer.
I don't quite understand when the CommentSubmit occurs. Is it when the page reloads? Or before?
Any indicators as to where I should start looking would be very helpful.
Thanks,
Kate
[edited by: Ocean10000 at 1:41 pm (utc) on Sep. 8, 2009]
[edit reason] Fixing Link [/edit]
Further googling revealed this MS bug: [support.microsoft.com...]
So, I *think* I am going to let it load in page28.aspx and do some url rewriting instead.
Oh joy.
Now all the images and links on the master page which contained "~" and runat=server are bouncing out of my virtual directory. I have pages on many levels so the links / images need to come from the root of the site.
I have looked at using VirtualPathUtility to stop this, but don't know where to start.
[msdn.microsoft.com...]
Ideally I don't want to have to call a method for every image / link etc on the site.
I think I read somewhere that VirtualPathUtility would sort of tell the "~" where to go to, but I might be confusing myself.
Not sure if this should be a new thread...? Sorry.
You might notice that the links and images are broken when debugging after changing this, to remedy this you can change the 'Virtual Path' property of the project to '/'. (Click on the project in the solution explorer and then change the settings in the Properties box.)
At some point I will have nested sites (/dotnettemplate/yearlyreview etc) using this template, which is why I want to avoid hard coding in the full path.
It might be an idea to take a step back and see if there may be better options open to you such as true URL rewriting or maybe System.Web.Routing [msdn.microsoft.com]
I've decided that I'm going to carry on with this version of my .NET template for a while, and then look at improving / rebuilding internal cms / moving to .NET MVC at a later date (when my .NET skills are a little better!).
Anyway, I'm here because the problem I had was caused by a true that should have been false.
Changing:
this.Context.RewritePath(string.Format("~/managed_content/pages/{0}/page{0}.aspx", GlobalVariables.PageID),true);
this.Context.RewritePath(string.Format("~/managed_content/pages/{0}/page{0}.aspx", GlobalVariables.PageID),false);
Should have read this a bit more closely: [msdn.microsoft.com...]
Ta, Kx