Post using Response.Write

  • Thread starter Thread starter Jer425
  • Start date Start date
J

Jer425

Hello all,

I'm trying to post to another page from asp.net and direct the user
there. I've looked through the group and found a lot of information.
The following code may work well for what I'm doing.

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click

** Response.Write("<!-- Include File='Example.aspx' -->")
Response.Write("<form name='Form2' action='UrlHere' method='POST' >")
** Response.Write("<% Example() %>")
Response.Write("<INPUT type='hidden' name='none' value='none'>")
Response.Write("</form>")
Response.Write("<script>")
Response.Write("document.Form2.Submit();")
Response.Write("</script>")

End Sub

The problem I'm having is trying to implement the include file and run
functions from it. If I remove the code for the function and the
include file (labeled with **) the post will work, but without them it
isn't working the way I need it to.

Does anyone know of a way that I can implement this include file into
the following code and run fuctions from it?

Thanks
 
Thank you for the response.

When I use the code below in html, I'm able to run the function from
the Example.aspx include file. Only when moving it to the code behind
with response.write is when I get a problem as I mentioned above.

<FORM id="Form2" action="UrlHere" method="post">

<!-- #Include File="Example.aspx" -->
<% Example() %>
<INPUT type='hidden' name='none' value='none'>
<INPUT TYPE="submit" VALUE="Submit" NAME="Submit">

</FORM>
 
That is because you are trying to use Response.Write as a time machine. ;)

The SSI (server side include) is performed before the ASP.NET code is
compiled. That means that once the code is running, it's too late to
make an include.

Also, you are trying to write ASP.NET code to the page to have it
executed. As the code of the page has already been compiled, it's too
late to add more code.

Whatever you write to the page using Response.Write will just end up in
the html code of the page.
 
Back
Top