PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

How to make an ASP.net 2.0 form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make an ASP.net 2.0 form

    I already have a <form runat="server"> tag for my asp.net page before the search, and I was hoping to use asp.net textboxes and image buttons to control the form action. I did some searching on the site and found nothing to show how to make a asp.net form to run the search.

    Here is the header:
    Code:
    <body>
    <form runat="server">
    <div id="mainwrapper">
    <div id="logo_p"><img src="images/body/logo_p.jpg" alt="Pencom" /></div>
    <!--Start Header-->
    <div id="header">
    <a href="index.aspx"><img src="images/body/logo.jpg" alt="Home" width="222" height="50" class="floatleft" title="Pencom Home" /></a>
    <div id="toplinks">
    <ul>
    <li class="nobullet"><a href="contact.aspx">Contact</a></li>
    <li><a href="locations.aspx">Locations</a></li>
    <li><a href="sitemap.aspx">Site Map</a></li>
    <li class="nospace"><asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="RedirectToLoginPage" /></li>
    </ul>
    <div id="search">
    <form action="zoom/search.aspx" method="get">
    <asp:TextBox ID="zoom_query" runat="server" Text="Search"></asp:TextBox> <asp:ImageButton ID="ImageButton1" runat="server" OnClick="zoom" ImageUrl="images/body/search1.jpg"   />
    <input type="text" style="font-size:8pt;" name="zoom_query" value="Search" onfocus="this.value=''" autocomplete='off' /><input type="image" src="images/body/search1.jpg" alt="Search Pencom" title="Search Pencom" style="vertical-align:bottom; border:0px;" />
    </form>
    </div>
    </div>
    </div>
    <!--End Header-->
    So there is a form inside of a form. Well this is ok in Firefox, but in IE doesn't like this and I'm getting a "Invalid postback or callback argument." error so I am trying to work around it and use an asp text box and button and have the action on the specific button. That way it validates the control and I don't have to have two forms on one page. Can someone show me an example in VB of how to post to the search.aspx page so it accepts the text box text in the search.

    I came up with this:
    Code:
        Protected Sub zoom(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
            Response.Redirect("zoom/search.aspx?zoom_query=" + zoom_query.Text)
        End Sub
    and it seems to work, but I don't know if I'm leaving out any functionality of the program. I'm using version 4 for reference.

    Thanks for the help in advance!

  • #2
    I'm not familiar with ASP.NET forms, so I am not sure how it would handle the form within a form approach. Can you add an "action=" attribute to the runat="server" form, and use just one form to achieve this?

    There shouldn't be any problem with the second approach of just redirecting to the URL with the query as a parameter. The only thing missing is the other parameters/options available from the default Zoom search form, eg. selecting "match any search words" or "match all", categories, results per pages, etc. You could add them in as part of the URL if needed. Refer to the form HTML given in this FAQ for more parameters:
    http://www.wrensoft.com/zoom/support...tml#searchform
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment

    Working...
    X