Solved

override form action in asp.net web control runat=server

Posted on 2002-05-07
5
601 Views
Last Modified: 2012-08-13
for my asp.net project I have a template file (default.aspx) that takes a page parameter to execute inside it. so every file on my server I access thru default.aspx so that it is loaded with the right borders/graphics around it. for example a link would look like  http://.../default.aspx?myinfo.aspx

default.aspx gets loaded and does its stuff, then calls server.execute(myinfo.aspx) and the end result is myinfo all dressed up. this method has been working great for a while, even post backs are fine (I just set action="default.aspx?mypage.aspx"). but I've recently ran into a problem.

the problem is with the asp.net web controls. they make a form with runat="server" and no action, when they postback they post directly to the page, bypassing my default.aspx template. when I try to specify an action its ignored. can anybody help me with a solution to this problem? really if I could just override the action for the web control everything would work perfectly - but its not working. please help!
0
Comment
Question by:gfody
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 300 total points
ID: 6994989
ASP.Net form posting is different from classic ASP form posting. You can't specify the action. The postbacks always happen to the same page. And thats what you are observing. After calling Server.Execute(myInfo.aspx) from Default.aspx, the control has been shifted to myInfo.aspx page. That becomes the current page for framwork and every postback event from web server controls will goto this page and not default.aspx.
I think you can an approach where Default.aspx page becomes base class for all the pages. Kind of a template. And then rest of the pages drive from this template default.aspx page.
Just an idea... what do you think
0
 
LVL 2

Author Comment

by:gfody
ID: 6995036
thanks for the suggestion. its not really a solution though as my default.aspx template is in use for the rest of site (and working nicely). when I'm using my own forms I specify default.aspx?mypage.aspx as the action and the postback works perfectly.. the problem with the .net controls is that its not letting me specify the action and posts back to mypage.aspx directly. If I could just override the action somehow it would work fine.

another reason that I need the default.aspx?mypage... functionality is that the entire site can be "skinned" to have a different look just by modifying default.aspx
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 6995232
Unfortunately this behavior is by design. all postbacks happen to current page only.
As far as skining or getting a common look for all pages goes, you can divide your default page into deifferent sections. And then each section can be a usercontrol or template control. And when a page needs to be generated based on the QueryString, you can pass that to the template. And that template generate output based on that value.
0
 
LVL 15

Expert Comment

by:gladxml
ID: 8795893
No comment has been added lately and it seems that this question have been abandoned. So it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question or invite a Moderator to close this question if there's no reply from you after seven days.

In the absence of responses, I will recommend the following:

To accept the comment and points awarded to naveenkohli

** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **


Just trying to help for the cleanup...
gladxml
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question