Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now