views:

61

answers:

2

Hello,

I added the standard code for google search in my site (taken from http://www.askdavetaylor.com/how_can_i_add_a_google_search_box_to_my_web_site.html):

when i compile and run the site, i get the following error (as soon as the page loads):

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

what to do?

A: 

Make sure to not use runat=server with that form. If that doesn't work, please post the exact code you are using, you are probably using a part of asp.net in a place you shouldn't. If possible, try keeping it to the html controls, in particular an asp.net button will be doing a asp.net postback which is not what you want.

eglasius
A: 

The easiest way to get rid of the error is to add EnableEventValidation="true" into the Page directive at the top of the aspx page. That will eliminate the error but I don;t think your code will work :). As Freddy points out, your code is trying to submit a client side form within a server-side form.

At the end of the day, a Google search is really just http://www.google.com/search?q=Your+search+term. You can easily achieve this with some simple javascript without any forms at all.

<input type="text"   name="q" size="25"
 maxlength="255" value="" />
<input type="button" onclick="location='http://www.google.com/search?q=" + document.getElementById("q").value + "'" value="Google Search" />

Might need some tweaking and escaping but it should give you the idea.

iZ