Postback on UserControls

Mar 18, 2009 at 11:26 PM
Hi,

I've got a problem with performing postback on UserControls I've written. When I perform a postback on a page that contains one of my custom Usercontrols (done as a part), the url is redirected to the .ascx file.

Is there anyway around this?

Cheers
Chris
Mar 19, 2009 at 11:38 AM
Here's an example:


Click on a page number and you'll see the URL change in the address bar
Mar 20, 2009 at 5:29 PM
I found the solution and it's a fairly easy one. You just change the Action property of the parent form in the UserControl, to the parent (the actual page, not the view) page. You obviously need a nicer solution for UserControls that work on multiple pages, here's an example:

protected void Page_Load(object sender, System.EventArgs e)
{
this.Page.Form.Action = "/Path/Mypage.aspx";
}

There's likely a simple inbuilt way of getting round this in N2 and Cristian probably has a solution but I couldn't find one.
Coordinator
Mar 21, 2009 at 3:48 PM
This sounds a bit strange. Can you share some more details around your solution? Where is the <form/> located? What page is the "current" (check CurrentPage)? What do you have in your /app_browsers?
Mar 22, 2009 at 2:41 PM
The problem was the App_Browsers folder missing (it's missing in the default minimal C# solution also).

The file "MaintainPostbackUrl.browser" solved the problem :)
Mar 22, 2009 at 2:49 PM
Note that that .browser file breaks my RequiredValidators....
The validation is not performed on the client site when that file is active....
Mar 22, 2009 at 3:25 PM
If you add it to the issue tracker it should get fixed. Can you post the Javascript errors too
Coordinator
Mar 22, 2009 at 10:57 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.