Solved

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

Posted on 2002-05-07
5
595 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Choose the older file FSO 6 49
Pass through dll 2 83
CDO.Message not able to send attachement 5 26
ASP/VB email question 4 35
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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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