Monday, March 26, 2012

Prevent popupcontrolextender from full postback.

I follow the sample popupcontrol from the samplewebsite package. I spent couple hours trying to figure out where I'm doing wrong: the asp:control, the popupcontrolextender, or the updatepanel. Everytime I click submit in the popup box it does a full postback. The popupcontrolextender's popupcontrolid is using asp:panel. I know the updatepanel inside the asp:panel is working, because I pulled it out from the popupcontrolextender and the asp:panel.

Maybe it is the asp:control I'm using, the asp:hyperlink to execute the popupcontrolextender. But, I need to use something similar to asp:hyperlink.

Here is my markup code:

1<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" CodeBehind="TestAjaxControlToolkit.aspx.vb" Inherits="AjaxSandbox.TestAjaxControlToolkit" %>
2<%@dotnet.itags.org. register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" >
5<head runat="server">
6<title>Ajax Control Toolkit</title>
7</head>
8<body>
9<form id="form1" runat="server">
10<asp:scriptmanager id="ScriptManager1" runat="server" />
11<%=DateTime.Now.ToString %>
12<br />
13If the date and time above change, means the whole page postback.
14<hr />
15<h3>PopupControl</h3>
16<asp:label id="lblFirstName" runat="server" text="First Name:" /> <asp:textbox id="txtFirstName" runat="server" /> <asp:hyperlink id="hypFirstNameNote" navigateurl="#" runat="server">[Note]</asp:hyperlink>
17<cc1:popupcontrolextender id="pceFirstName" runat="server" targetcontrolid="hypFirstNameNote" popupcontrolid="pnlNotePopup" position="bottom" />
18<br />
19<br />
20<asp:label id="lblLastName" runat="server" text="Last Name:" /> <asp:textbox id="txtLastName" runat="server" /> <asp:hyperlink id="hypLastNameNote" navigateurl="#" runat="server">[Note]</asp:hyperlink>
21<cc1:popupcontrolextender id="pceLastName" runat="server" targetcontrolid="hypLastNameNote" popupcontrolid="pnlNotePopup" position="bottom" />
22<br />
23<div style="visibility:hidden;position:absolute;">
24<asp:panel id="pnlNotePopup" runat="server">
25<div style="width:320px;padding:0.2em 0.2em;border:1px outset gray;background:white;">
26<asp:updatepanel id="upNotePopup" runat="server">
27<contenttemplate>
28<asp:textbox id="txtNote" runat="server" rows="6" width="98%" textmode="MultiLine" />
29<asp:button id="btnNoteSubmit" runat="server" text="Submit" onclick="btnNoteSubmit_Click" />
30<asp:hiddenfield id="hidNote" runat="server" />
31</contenttemplate>
32</asp:updatepanel>
33</div>
34</asp:panel>
35</div>
36<br />
37<asp:updatepanel id="upOutputSubmit" runat="server">
38<contenttemplate>
39<asp:button id="btnOutputSubmit" runat="server" text="Submit" onclick="btnOutputSubmit_Click" />
40<br />
41<asp:label id="lblOutput" runat="server" />
42</contenttemplate>
43</asp:updatepanel>
44<h3>DropDown</h3>
45</form>
46</body>
47</html>

Here is my vb.net code:

1Public PartialClass TestAjaxControlToolkit
2Inherits System.Web.UI.Page
34Protected Sub btnNoteSubmit_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)
5 hidNote.Value &= HttpUtility.HtmlEncode(DateTime.Now.ToLongTimeString &": " & txtNote.Text &"<br />")
6 txtNote.Text =String.Empty
7End Sub
89 Protected Sub btnOutputSubmit_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)
10 lblOutput.Text ="<br /><strong>Output General:</strong><br />" & txtFirstName.Text &" " & txtLastName.Text &"<br />" &"<strong>Output Note:</strong><br />" & HttpUtility.HtmlDecode(hidNote.Value)
11End Sub
1213End Class

*Bump*

Anybody?


*Bump*

Anybody home?


The sample seems to work fine for me with the 61106 Toolkit release and ASP.NET AJAX Beta 2. Try that configuration, please.

No comments:

Post a Comment