Good evening,
This is probably me just miss understanding the AJAX UpdatePanel, but I thought I could do things without it having to postback to the server.
Unfortantaly the code Ive written fires the postback still.
Any ideas how I can fire my event handlers without it posting back like it is at the moment?
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"
divTextBox1_AutoComplete.InnerText = "Textbox text is " & Textbox1.Text
End Sub
End Class
ASPX Code:
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplication21._Default" EnableEventValidation="false"%>
<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>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Textbox1_Blur" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Textbox1_KeyUp" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>