Problems with Forms

Nov 27, 2008 at 10:04 PM
I have a couple of forms that are requests to other sites for info, here is one example
<FORM method="GET" action="">
<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?

Dec 7, 2008 at 9:52 AM
Edited Dec 7, 2008 at 10: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 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... 


<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" />

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("" & txtCallSign.Text, True)
End Sub


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("" & 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 9: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 yet