473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Modifying form action attribute

Hi

Is there a way to modify the action attribute of a form just before the
initial GET for that page renders the HTML?

I have a case where I do a GET on a URL like so:
http://www.somewebsite.com/mydisplay...equerystring=0

This page renders like this:

<form method="post" action="mydisplay.aspx?somequerystring=0"
</form>

What I want is the page to be rendered as usual but before that I need
to modify the action attribute to point to something else (actually i
need to change the querystrings in the action URL). I have been
looking into MSDN but I think I may not be on the right path. Any
pointers are greatly appreciated.

thanks!

Nov 19 '05 #1
2 1237

"Dilip" <rd*****@lycos.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi

Is there a way to modify the action attribute of a form just before the
initial GET for that page renders the HTML?

I have a case where I do a GET on a URL like so:
http://www.somewebsite.com/mydisplay...equerystring=0

This page renders like this:

<form method="post" action="mydisplay.aspx?somequerystring=0"
</form>

What I want is the page to be rendered as usual but before that I need
to modify the action attribute to point to something else (actually i
need to change the querystrings in the action URL). I have been
looking into MSDN but I think I may not be on the right path. Any
pointers are greatly appreciated.

thanks!

Look into overriding the page render as follows.

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

Dim _stringBuilder As StringBuilder = New StringBuilder()
Dim _stringWriter As StringWriter = New StringWriter(_stringBuilder)
Dim _htmlWriter As HtmlTextWriter = New HtmlTextWriter(_stringWriter)
MyBase.Render(_htmlWriter)

' at this point _stringBuilder contains the html that will be rendered
'you then manipulate _stringBuilder. when done you write it back out

writer.Write(_stringBuilder.tostring())

End Sub

Of course if the page isn't posting back to itself, its state will be all
messed up I think. Another method, if you are just adding a simple secondary
form to a webpage is to build the html for the form by hand in a literal
control and add it to a placeholder using .. plcID.controls.add(new
literalcontrol(formshtmltextasstringbuilder.tostri ng())) This must be done
outside of any forms with runat tags.

Mike
Nov 19 '05 #2
On Wed, 06 Jul 2005 09:53:18 -0700, Dilip wrote:
Hi

Is there a way to modify the action attribute of a form just before the
initial GET for that page renders the HTML?

I have a case where I do a GET on a URL like so:
http://www.somewebsite.com/mydisplay...equerystring=0

This page renders like this:

<form method="post" action="mydisplay.aspx?somequerystring=0"
</form>

What I want is the page to be rendered as usual but before that I need
to modify the action attribute to point to something else (actually i
need to change the querystrings in the action URL). I have been
looking into MSDN but I think I may not be on the right path. Any
pointers are greatly appreciated.

thanks!

You can do myform.action = yoururl at the client as soon as the page loads
(on the onload event).

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bruce Duncan | last post by:
I'm new to PHP...and my previous post was a bit premature. I've narrowed my problem down to this: I have this very simple form in test1.php <form name='formx6' action="testz.php?varxy=1">...
13
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine....
4
by: Sarah | last post by:
Hi all. I have a form, and several text and image links on it that should submit the form with different actions. I prepared a simple page with just the code that's not working. PROBLEM:...
5
by: Jan Gregor | last post by:
Hello I want to change attribute action in form. Problem is that in that form is also input with name action. Unfortunately renaming of that input is worst case because many servlets depend on...
10
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
2
by: belgie | last post by:
Whereas in Asp I could submit my form contents to any other Asp page, it appears that in Asp.NET the primary Asp form will only submit to itself. I have tried changing the Action attribute in the...
2
by: Matt | last post by:
I have a client that requires a custom extension to all of the aspx pages. I have created an HttpHandler to receive the custom extension but where do I capture the response of the form with an...
4
by: wwwmike | last post by:
How can I overwrite the <FORM action=attribute? I can add new attributes with Dim xx As System.Web.UI.HtmlControls.HtmlForm xx = Page.FindControl("form1") xx.Attributes.Add("something",...
4
by: Roshawn | last post by:
Hi, I have a web page that contains an html form and has a few controls in it. The html form and its controls are all server controls. However, I've set the enableViewState attribute of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.