Problems with Forms

Nov 27, 2008 at 9:04 PM
I have a couple of forms that are requests to other sites for info, here is one example
<FORM method="GET" action="http://www.qrz.com/callsign.html">
<B>QRZ callsign lookup:
<INPUT type="text" name="callsign" size="8">
<INPUT type="submit" value="Search"></B></FORM>

When I add this to any page in source mode the form displays properly but when the button is clicked it just reloads the page that the form is on, completely
I've had this problem before and can't remember how I got round it can anyone help?

Martin
Dec 7, 2008 at 8:52 AM
Edited Dec 7, 2008 at 9:10 AM
I'm not a great programmer but as far as I know, all contents are inside the a FORM. This allows ASP.Net to use post back events. In short, when you create a form, the main form is getting submitted which ofcourse is posting all the contents back to same page. So you just see it as Page reload. You can either use ASP.net controls like textbox and buttons to generate a pseudo form and then handle the button_click event to post the content to the values as follows... 

HTML

<div id="QRZForm">
    <fieldset id="QRZFields">
        <label for="txtCallSign">Call Sign</label><asp:TextBox ID="txtCallSign" runat="server"></asp:TextBox><br />
        <asp:Button runat="server" ID="btnSubmit" Text="Submit" />
    </fieldset>
</div>

Then in VB.Net u use the following event to submit your form(since it's a GET, you just need to buildup a qeuerystring)

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    Response.Redirect("http://www.qrz.com/callsign.html?callsign=" & txtCallSign.Text, True)
End Sub

OR

keep your form as it is and add following line of code to page_load event in codebehind file

If Page.Request("callsign") <> String.Empty Then
    Response.Redirect("http://www.qrz.com/callsign.html?callsign=" & Page.Request("callsign"))
End If

u'll need to convert it into C# code before u can consume it.



Hope this helps...
Dec 8, 2008 at 8:23 AM
Thanks NoisySilence, this just leaves me one question, as I've tried the other way. and inputting .net code into FCKeditor doesn't seem to work, so I've created a page called links and given it the virtual path ~/links.aspx
so how do I get a code behind page to work with this or do I manually have to create the links.aspx page before hand??

Sorry I was not to bad with asp3 but seemingly haven't got my head around asp.net yet