Solved

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

Posted on 2002-05-07
5
609 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

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…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

726 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