"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