Ive been playing around with ASPx and decided to try and get a div to show when a user enters some data into a textfield, and hide when the focus is lost.
However I keep getting the following error message, and even thought Ive tried to use the ClientScript.RegisterForEventValidation("Textbox1_Blur") which tells me I need to do this in render but cant find the render event.
I know I can use the EnableEventValidation="false", however this removes the built in security which Id like to keep if possible.
The error message I get is:-
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> 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.
Any ideas how I can prevent the error, but keep the security on?
Thanks in advance
ASPx Code:-
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplication21._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="divTextBox1_AutoComplete" runat="server" style="border: thin solid #000000; background-color: #00FFFF; position: absolute; z-index: auto; visibility: hidden">
Hello this is a test<br/>
This is a second line<br/>
This is third
</div>
<asp:TextBox id="Textbox1" runat="server" />
<asp:Button id="Textbox1_Blur" runat="server" Visible="false" />
<asp:Button id="Textbox1_KeyUp" runat="server" Visible="false" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
VB Code:-
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Textbox1.Attributes.Add("onBlur", ClientScript.GetPostBackEventReference(Me.Textbox1_Blur, ""))
Textbox1.Attributes.Add("onKeyUp", ClientScript.GetPostBackEventReference(Me.Textbox1_KeyUp, ""))
'ClientScript.RegisterForEventValidation("Textbox1_Blur")
'ClientScript.RegisterForEventValidation("Textbox1_KeyUp")
End Sub
Private Sub Textbox1_Blur_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Textbox1_Blur.Click
divTextBox1_AutoComplete.Attributes("display") = "none"
End Sub
Private Sub Textbox1_KeyUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Textbox1_KeyUp.Click
divTextBox1_AutoComplete.Attributes("display") = "inline"
End Sub
End Class