Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

Monday, March 26, 2012

PageMethods is undefined

Hi all,

I'm getting "PageMethods is undefined" while clicking on the OK button which is in the "ajaxToolkit:ModalPopupExtender".How to overcome this issue? Below is my code.

aspx page:

<script>
function onOk() {

//$get('Paragraph1').className = styleToSelect;
PageMethods.callservermethod()
}
</script>


<form id="ajaxForm" runat="server">
<asp:ScriptManager ID="manager" runat="server" EnablePageMethods="True">
</asp:ScriptManager>
<%-- EnablePartialRendering="true" EnableScriptGlobalization="true" EnableScriptLocalization="true"--%>

<div>
<asp:Label ID="fnamelbl" Text="First Name" runat="server"></asp:Label>
<asp:TextBox ID="fnamectl" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="fnameval" ControlToValidate="fnamectl" ErrorMessage="<b>Required Field<br />Please Enter</b>" Display="dynamic" runat="server"></asp:RequiredFieldValidator>
<ajaxToolkit:ValidatorCalloutExtender ID="ajaxfnameval" TargetControlID="fnameval" runat="server" HighlightCssClass="validatorCalloutHighlight"></ajaxToolkit:ValidatorCalloutExtender>
<asp:Label ID="lnamelbl" Text="Last Name" runat="server"></asp:Label>
<asp:TextBox ID="lnamectl" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="lnameval" ControlToValidate="lnamectl" ErrorMessage="<b>Required Field<br />Please Enter</b>" Display="dynamic" runat="server"></asp:RequiredFieldValidator>
<ajaxToolkit:ValidatorCalloutExtender ID="ajaxlnameval" TargetControlID="lnameval" runat="server" HighlightCssClass="validatorCalloutHighlight"></ajaxToolkit:ValidatorCalloutExtender>
<asp:Button ID="savebtnctl" Text="Save" runat="server" />
</div>

<%-- <p id="Paragraph1"><%= GetContentFillerText() %></p><br />
<p id="Paragraph1"></p><br />--%>


<asp:Panel ID="Panel1" runat="server" Style="display: none" CssClass="modalPopup">
<asp:Panel ID="Panel3" runat="server" Style="cursor:move;background-color:#DDDDDD;border:solid 1px Gray;color:Black">
<div>
<p>The below details are stored in DB</p>
</div>
</asp:Panel>
<div>
<p><%=fnamectl.Text%><br /><%= lnamectl.Text %></p>
<p style="text-align: center;">
<asp:Button ID="OkButton" runat="server" Text="OK" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</p>
</div>
</asp:Panel>

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server"
TargetControlID="savebtnctl"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
OkControlID="OkButton"
OnOkScript="onOk()"
CancelControlID="CancelButton"
DropShadow="true"
PopupDragHandleControlID="Panel3" />
</form>

aspx.vb page:


Partial Class _Default
Inherits System.Web.UI.Page

Dim ajxwork As New action

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub
'Protected Sub savebtnctl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles savebtnctl.Click
' SetCtlToOjects()
' Dim flag As Integer = ajxwork.Save()
' If flag = 1 Then
' MsgBox("Your data has been saved.")
' Else
' MsgBox("Sorry!!! Your data failed to be saved.")

' End If
'End Sub
<WebMethod()> _
Public Sub callservermethod()

SetCtlToOjects()
Dim flag As Integer = ajxwork.Save()
If flag = 1 Then
MsgBox("Your data has been saved.")
Else
MsgBox("Sorry!!! Your data failed to be saved.")

End If
End Sub

Public Sub SetCtlToOjects()

ajxwork.firstname = fnamectl.Text
ajxwork.lastname = lnamectl.Text

End Sub

End Class

class.vb


Public Class action

Private _firstname As String
Private _lastname As String

Public Property firstname() As String
Get
Return _firstname
End Get
Set(ByVal value As String)
_firstname = value
End Set
End Property
Public Property lastname() As String
Get
Return _lastname
End Get
Set(ByVal value As String)
_lastname = value
End Set
End Property

'<System.Web.Services.WebMethod()> _
Public Function Save() As Integer
Dim SqlConn As New SqlConnection(ajaxconnection.ajxconnect)
Dim SqlCmd As New SqlCommand
SqlConn.Open()
SqlCmd.Connection = SqlConn
SqlCmd.CommandType = CommandType.StoredProcedure
SqlCmd.CommandText = "asp_patsave"
'SqlCmd.Parameters.Add(New SqlParameter("@dotnet.itags.org.firstname", SqlDbType.NVarChar))
'SqlCmd.Parameters.Add(New SqlParameter("@dotnet.itags.org.lastname", SqlDbType.NVarChar))
SqlCmd.Parameters.AddWithValue("@dotnet.itags.org.firstname", _firstname)
SqlCmd.Parameters.AddWithValue("@dotnet.itags.org.lastname", _lastname)
SqlCmd.ExecuteNonQuery()
SqlCmd.Dispose()
SqlConn.Dispose()
Return 1
End Function
End Class

Thanks in Advance :)

Hi,

Please note that a pageMethod has to be static(c#) / shared(vb) .

Change the line Public Sub callservermethod() to Public Shared Sub callservermethod() and try again.

Hope this helps.

PageNavigator!

<div id="pageNavigator">
<input type="button" id="firstPageButton" value="<<" />
<input type="button" id="previousPageButton" value="<" />
<span id="pageIndexLabel"></span>
<span id="pageCountLabel"></span>
<input type="button" id="nextPageButton" value=">" />
<input type="button" id="lastPageButton" value=">>" />
</div>

I need to use image buttons for navigation and that works fine, but my question is how can I make certain image to change the src (to a disabled image) when it reaches either the very first page or very last page!

Please advice!

Hi,

supposed you've declared an image like:

<img id="myImage" src="http://pics.10026.com/?src=enabledImage.gif" alt="" />

then you can do it using pure Javascript:

if(firstPageReached || lastPageReached) {
document.getElementById('myImage').src = 'disabledImage.gif';
}

or Atlas:

var myImage = new Sys.UI.Control($('myImage'));
myImage.initialize();

if(firstPageReached || lastPageReached) {
myImage.set_imageURL('disabledImage.gif');
}

all understood, but how can I attach the event that it has reached the end of page or last of page?
Hi,

this really depends on how you have designed your PageNavigator (are you using server controls? Did you implement a client control?). If you need some info about how to raise events in the Atlas framework, please checkthis article.

below you will find my xml script. Please help me if you can!

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<listView id="CustomersResults" itemTemplateParentElementId="CustomersResults_itemTemplateParent" >
<layoutTemplate>
<template layoutElement="CustomersResults_layoutTemplate" />
</layoutTemplate>
<itemTemplate>
<template layoutElement="CustomersResults_itemTemplate">
<label id="CustomersResults_Name">
<bindings>
<binding dataPath="Name" property="text" />
</bindings>
</label>
<label id="CustomersResults_CustomerId">
<bindings>
<binding dataPath="CustomerId" property="text" />
</bindings>
</label>
<label id="CustomersResults_Description">
<bindings>
<binding dataPath="Description" property="text" />
</bindings>
</label>
<image id="CustomersResultsImageThumbPath">
<bindings>
<binding dataPath="CustomerID" property="imageURL" transform="DoAdditionalImageHandling" />
<binding dataPath="CustomerName" property="alternateText" />
</bindings>
<behaviors>
<hoverBehavior hover="ImageHandler" />
</behaviors>
</image>
</template>
</itemTemplate>
<bindings>
<binding dataContext="CustomersResultsview" dataPath="filteredData" property="data" />
</bindings>
</listView>
<dataView id="CustomersResultsview" pageSize="6">
</dataView>

<dataNavigator id="CustomersResultspageNavigator" dataView="CustomersResultsview"/>
<button id="CustomersResultspreviousPageButton" parent="CustomersResultspageNavigator" command="previousPage">
<bindings>
<binding property="enabled" dataPath="hasPreviousPage"/>
</bindings>
</button>
<label id="CustomersResultspageIndexLabel" parent="CustomersResultspageNavigator">
<bindings>
<binding property="text" dataPath="pageIndex" transform="Add"/>
</bindings>
</label>
<label id="CustomersResultspageCountLabel" parent="CustomersResultspageNavigator">
<bindings>
<binding property="text" dataPath="pageCount"/>
</bindings>
</label>
<button id="CustomersResultsnextPageButton" parent="CustomersResultspageNavigator" command="nextPAGE">
<bindings>
<binding property="enabled" dataPath="hasNextPage"/>
</bindings>
</button>
<button id="CustomersResultsfirstPageButton" parent="CustomersResultspageNavigator" command="FIRSTPage">
</button>
<button id="CustomersResultslastPageButton" parent="CustomersResultspageNavigator" command="lastpage">
</button>
</components>
<references>
</references>
</page>
</script>

PageRequestManagerParseErrorException

Hello. I'm have the problem with UpdatePanel. When the user does click on de button I call a method

Button1_Click

This method call other page in modo modal where the user type a password. If this password is ok I'll try to use

UpdatePanell2.Update() but I can′t call the page2 in modo modal because appear this error.

Read this to avoid this issue:

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx

PageRequestManagerParserErrorException caused by Response diddling?

I am porting an old app that downloads a csv file by writing into Response.OutputStream when a button is pushed on the form. The button is contained in an asp:Panel that can be made visible or not, so the Panel needs to be contained in the UpdatePanel.

If the asp:Panel and button are in an update panel, I get PageRequestManagerParserErrorException. If the panel and button are NOT in an UpdatePanel, the download works okay, but of course, I lose the ability to show/hide the asp:Panel.

My question is--is there a way to have a button in an UpdatePanel, but tell it NOT to participate in partial page rendering?

Or is there a better way to do the download??

Thanks,

R.L.

Hi Rlparker,

If you want a button not to participate in partialrendering then you have to make sure that you the button as a postback trigger. This will make sure that the button will act normally as a normal button event. See:

http://ajax.asp.net/docs/mref/T_System_Web_UI_PostBackTrigger.aspx

Hope this helps.

Regards,


Sorry

"you have to make sure that you the button as a postback trigger"

you have to make sure that you define the button as a postback trigger

Regards,


Thanks!!

R.L.

PageRequestManagerParserErrorException

I really hope someone can help me...

Scenario:

A button inside an UpdatePanel
If when I click the button I execute a Response.Redirect inside the button's event handler I get aPageRequestManagerParserErrorException exception.

This didn't happen with any of the betas (just updated to 1.0).

Any ideas?

Can you post your code. Do you by any chance call Response.Flush?
The code is quite large but I have found that this can be very easily reproduced.
To reproduce the problem you just have to enclose a button that executes Response.Redirect inside an UpdatePanel:

HTML Code:

<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Login" %><%@. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <table id="tblLogin"> <tr> <td>Login</td> <td><asp:TextBox ID="txtLogin" runat="server"></asp:TextBox></td> </tr> <tr> <td>Password</td> <td><asp:TextBox ID="txtPassword" TextMode="Password" runat="server"></asp:TextBox></td> </tr> <tr> <td colspan="2"> <asp:UpdatePanel ID="testPanel" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Button ID="btnLogin" runat="server" Text="Login" /> </ContentTemplate> </asp:UpdatePanel> </td> </tr> </table> <asp:Label id="lblErrorMsg" runat="server" ForeColor="Red"></asp:Label> <div id="dInvBrowser" class="errMsg" style="display:none; color:#FF0000; font-weight:bold;">Por favor, solamente utilice Internet Explorer 6.0 (o superior) para acceder al sistema</div> <script language="javascript" type="text/javascript">if(!IE || SM || OP || KQ || (BV<6)) {//document.getElementById("tblLogin").style.display="none";//document.getElementById("dInvBrowser").style.display="block";}</asp:Content>
Code Behind:
Protected Sub btnLogin_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnLogin.Click
Response.Redirect("/testpage.aspx")
End Sub
If I remove the "testPanel" then everything works just fine.
Anyone?Help on this issue will be GREATLY appreciated...

Is the page in question protected by a rolemanager/roleprovider? If so see:

http://forums.asp.net/thread/1555817.aspx


No...
Remember this was working perfectly before installing the 1.0 final release of ASP.NET AJAX

Also, you should be able to easily reproduce it: just create an UpdatePanel, insert a button and then simply call Response.Redirect("somee_page.aspx") in the button's click event.


I didn't try your exact code, but I tried this code, and it worked fine... can you spot any differences?

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> public void button_click(object sender, EventArgs e) { Response.Redirect("http://www.microsoft.com"); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="sm" runat="server" /> <asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Button ID="button" runat="server" OnClick="button_click" Text="Click Me" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Thank you SO much Steve!

By just looking at your code I realized I had something wrong with my application: I did not correctly upgrade from the last beta to the 1.0
So I re-read the documentation to perform the upgrade and everything is now working perfectly.

Again, thank you VERY much.


This a must read from Eilon Lipton's Technical blog on MicrosoftASP.NET and ASP.NET AJAX when trying to solvePageRequestManagerParserErrorException errors!

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx?CommentPosted=true#commentmessage A

Saturday, March 24, 2012

PageRequestManagerServerErrorException with 500 error code

In javascript I'm setting the value property of a button within an update panel before calling click() on the button to refresh the update panel. (I need to refresh an update panel and pass extra data on the callback, and no one on this forum has yet described a better way of doing it than this.)

This was all working in tests that I did last week, but I'm now getting the following error message box in IE:

"Sys.WebForms.PageRequestManagerServerErrorException: An unkown error ocurred while processing the request on the server. The status code returned from the server was: 500"

Any ideas?

I have the same error but on a couple of dropdown which update one another's datesource with updatePanels.

If i change the value of the first dropdown for several times, always the third tine gives this error.

I found on a post the setting TRACE off resolves but not for me.

Any ideas ?

Just try to change frequently some controls which use updatepanels (for other controls) and see what's happen.

Thank's

Sorin


I found also that If I have more than 3 UpdatePanels in a Page I get this error after 3 callbacks.

If I have on page Trace="false"and "EnableEventValidation="true"

I get this error:

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.

Thank's again


I've also tried setting the value of a hidden field and a hidden textbox and both raise the same error.

I cannot even paste data into a textbox and then do a postback without getting this error.

I'm also EXTREMELY TIRED OF MICROSOFT IGNORING ALL OF MY POSTS!!!!!!!!!!! Angry

Panel close button with AJAX

Hello All,

I want to use this wonderful AJAX Framework to something very simple:

Inside an UpdatePanel I have a Panel. Now just below the Panel I want to place a button or link that when clicked will hide the Panel and do this client side (without requiring a post back). I know how to do this with a postback and a method that sets Panel.Visible = false, but I don't want to call the server for this, just hide the Panel client side.

So I ask to the MS AJAX experts out there: what is the easy and elegant way of doing this with MS AJAX Framework and/or AJAX Control Toolkit.

Thank you!

David

Use this JS for the button/link click: $get('PanelClientID').style.display = 'none';


Hi Neutrino,

My understanding of what your want is to make your panel which is indside an UpdatePanel without any postbacks. If I have misunderstood, please feel free to let me know.

You can use $get(Panel's ClientID).style.display = 'none'. Here is the sample:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"><%=DateTime.Now.ToString()%> </asp:Panel> <asp:Button ID="Button1" runat="server" Text="Button"OnClientClick="return hidePanel()"/> </ContentTemplate> </asp:UpdatePanel> <script type="text/javascript" language="javascript">function hidePanel(){ $get("<%= Panel1.ClientID%>").style.display='none'; return false; } </script> </form></body></html>

Note: Please pay special attention to the part of "Bold". IfOnClientClick don't return false, a postback will be occured in this case.

Best regards,

Jonathan


Thanks to both. Great simple solution.

Panel Default Button Event Doesnt Fire On Second Submit

I have one UpdatePanel surrounding a asp panel. Inside the panel I have one repeater, two buttons, and two labels. Inside the repeater's ItemTemplate I have an ImageButton and TextBox.

Here is the ASP Code:

1<asp:UpdatePanel ID="AdvancedSearchUpdatePanel" runat="server" UpdateMode="conditional" RenderMode="block" ChildrenAsTriggers="true">2 <ContentTemplate>3 <asp:Panel ID="AdvancedSearchPanel" runat="server" DefaultButton="SubmitSearchButton">4 <asp:Repeater ID="AdvancedSearchRepeater" runat="server">5 <HeaderTemplate>6 <table class="searchButton">7 <tr>8 <td colspan="100%">9 <asp:Label ID="KeywordLabel" runat="server" Text="Search By Keyword" Width="100%" Font-Bold="true"/>10 </td>11 </tr>12 </HeaderTemplate>13 <ItemTemplate>14 <tr>15 <td colspan="100%">16 <table cellpadding="0" cellspacing="0" style="padding-right:5px">17 <tr>18 <td>20 <asp:ImageButton ID="DeleteCriteriaButton" runat="server" ImageUrl="~/Resources/Images/close.gif" AlternateText="Click to Delete" OnClick="DeleteCriteriaButton_Click" />21 </td>22 <td>23 <asp:TextBox ID="KeywordTextBox" runat="server" Text='<%# Container.DataItem%>' CssClass="keywordSearch" Width="123px" OnTextChanged="KeywordTextBox_TextChanged" />24 </td>25 </tr>26 </table>27 </td>28 </tr>29 </ItemTemplate>30 <FooterTemplate>31 </table>32 </FooterTemplate>33 </asp:Repeater>34 <table class="searchButton">35 <tr>36 <td>37 <asp:Button ID="AddAnotherSearchButton" Text="Add Criteria" runat="server" OnClick="AddAnotherSearchButton_Click" />38 </td>39 <td>40 <asp:Button ID="SubmitSearchButton" Text="Submit Search" runat="server" OnClick="SubmitSearchButton_Click" />41 </td>42 </tr>43 <tr>44 <td colspan="100">45 <asp:Label ID="ReadableSqlString" runat="server" />46 </td>47 </tr>48 <tr>49 <td colspan="100">50 <asp:Label ID="ErrorLabel" runat="server" ForeColor="red"/>51 </td>52 </tr>53 </table>54 </asp:Panel>55 </ContentTemplate>56</asp:UpdatePanel>
My problem is that the default button for the panel is the SubmitSearchButton. 
On the first press of the enter key everything works as it should. 
On the second press of the enter key the DeleteCriteriaButton's (ImageButton) event gets fired because it is the first button in the panel. 
The only way I have seen to get around this is to put a button before the ImageButton that has a width of zero and have its event call the SubmitSearchButton event and everything works as should. 
Does anyone know a cleaner way around this problem or a reason this is happening. 
 
Thanks in advance.
There is a free component that allows you to assign a button to the "enter-pressed" client side event of input controls. If you type some text in textbox and press Enter, the form will postback, and the serverside click event of your button is fired.You don't need to write any code You only need to use control's "DefaultButton" property. It you are a beginner programmer this could be a life saver. More about MetaBuilders DefaultButtons Control you can find athttp://www.metabuilders.com/Tools/DefaultButtons.aspx
Wish this can help you.
You can specify a default button through javascript when pressing enter key.Try to take a look at this reading for details -http://www.beansoftware.com/ASP.NET-Tutorials/Accept-Enter-Key.aspx
Here are some sample codes for your reference.
TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}} else {return true}; ");
Wish the above can help you.

DefaultButton is working fine for me on a simpler example:

<%@. Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void click(object sender, EventArgs e) { label1.Text = string.Format("{0} pressed at {1}", ((Control)sender).ID, DateTime.Now.ToString()); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="up1" runat="server"> <ContentTemplate> <asp:Panel ID="panel1" runat="server" DefaultButton="button2"> <asp:TextBox ID="text1" runat="server" /> <asp:Button ID="button1" runat="server" OnClick="click" Text="one" /> <asp:Button ID="button2" runat="server" OnClick="click" Text="two" /> </asp:Panel> <asp:Label ID="label1" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

This does what you'd expect... every time you type something and press enter, the label displays "button2 pressed at " followed by the current time.

Your sample is considerably more complicated (and hard to reproduce, since I would need to provide a datasource etc.). Could you try simplifying your code to see at what point the issue goes away?


You can't forget that in my code I have repeaters. This might be the problem. My quick fix is to put a button before the delete button and set it to call the submit button's click event. I know this is a hack and I'm working on other issues. Your help is greatly appreciated. FYI, the datasource of the repeater is a List<string>.
I tested your code with a asp:Panel(asp:Repeater) in a asp:UpdatePanel in my PC.My test enviroment isWindows Server 2003 Enterprise,VS.NET 2005 and Ajax RC1.0. I found it?could?work?fine.If?you?click?the?TextBox?and?press?Enter?key in theasp:Panel, the?default?button?of?the?asp:Panel will?be?triggered.If?the?current?focus?was?moved to?the?outside?of?the?asp:Panel?and?press?Enter?key, the?default?button?of?the?asp:Panel?can't?be?triggered.So if you want to pressEnter key in anywhere of the current web form and the default button of theasp:Panel will be triggered, try to focus on aTextBox of theasp:Panel throughjavascript when pressingEnter key in the web form.This should work fine for you.
Sample Code: document.forms[0].elements['txtBox'].focus();
Wish this can help you.
This works in Internet Explorer 7, but not in Fire Fox 2. I'm soooo surprised.

Panel shows before Popup

Hi

I got a Button, a textbox a Panel in my page, when the page is loaded, the Panel will filled with pictures and link, then then the button is click, it will popup the panel as ModalPopup, when user clicked on the link accompanied with the picture, the code assigned will send to the textbox.

My problem is as the page is shows, I can see the picture populated inside the panel(which suppose to be invisible after using ModalPopupExtender), then it hidden again, but things works. Then I wanted to populate the code to my textbox using UpdatePanel, but it just cause the page to post back, here attached with my codes, hope will got a solution or a pointer from you guys, thanks.

Imports System.Data.sqlclientPartialClass _DefaultInherits System.Web.UI.PageDim conAs New SqlConnection("server=localhost;database=wardrobe;integrated security=true;")Dim comAs New SqlCommand()Dim drAs SqlDataReaderPrivate Sub linkClick(ByVal senderAs Object,ByVal eAs System.EventArgs)Dim idsAs LinkButton =CType(sender, LinkButton) TextBox1.Text = ids.IDEnd Sub Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadDim imgAs ImageDim lnkAs LinkButtonDim tablesAs New TableDim rowsAs TableRowDim colsAs TableCellDim colAs Integer = 1 com.Connection = con com.CommandText ="Select * From tblCollar"Try con.Open() dr = com.ExecuteReader rows =New TableRow() tables.CellSpacing = 10While dr.ReadIf col = 3Then col = 0 img =New Image() img.ID ="Img" & dr("code").ToString img.ImageUrl = dr("Picture").ToString img.Width = 100 img.Height = 100 img.ImageAlign = ImageAlign.TextTop lnk =New LinkButton lnk.Text ="[Select]" lnk.ID = dr("Code").ToString lnk.PostBackUrl ="default.aspx"AddHandler lnk.Click,AddressOf linkClick cols =New TableCell() cols.Controls.Add(img) cols.Controls.Add(lnk) rows.Cells.Add(cols) tables.Rows.Add(rows) rows =New TableRow()Else img =New Image() img.ID ="Img" & dr("code").ToString img.ImageUrl = dr("Picture").ToString img.Width = 100 img.Height = 100 img.ImageAlign = ImageAlign.TextTop lnk =New LinkButton lnk.Text ="[Select]" lnk.ID = dr("Code").ToString lnk.PostBackUrl ="default.aspx"AddHandler lnk.Click,AddressOf linkClick cols =New TableCell() cols.Controls.Add(img) cols.Controls.Add(lnk) rows.Cells.Add(cols)End If col += 1End While Panel1.Controls.Add(tables)Catch exAs ExceptionFinally con.Close()End Try End SubEnd Class 

Histephensaw,

It is not recommended to add the line number to your source code.Would you modify it and share your Aspx source code here?


Hi,

I had uploaded my project files and SQL Server 2005 backup files, please help me check my problem, thanks.

http://stephensaw.googlepages.com/BuildingModule.zip


Hi stephensaw,

I've got everything ready. But I'm not sure about what you really what to do now? Do you what to post a asynchronous Request to the server?

If yes, here is the sample:

<%@. Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> if (window.screen) { this.moveTo(0, 0); this.resizeTo(screen.availWidth,screen.availHeight) } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="updateCollar" runat="server"> <ContentTemplate> Please select a collar design form our gallery:  <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:TextBox ID="txtCode" runat="server" ReadOnly="True"></asp:TextBox> <asp:Button ID="btnBrowse" runat="server" Text="Browse" OnClick="btnBrowse_Click" /> <div style="display: none"> <asp:Button ID="btnPopTrigger" runat="server" Text="Button" /> </div> <cc1:ModalPopupExtender ID="PopupCollar" runat="server" BackgroundCssClass="ModalPopupBackground" PopupControlID="pnlPopup" TargetControlID="btnPopTrigger"> </cc1:ModalPopupExtender> <asp:Panel ID="pnlPopup" runat="server" Height="500px" Width="630px" BackColor="White"> </asp:Panel>   </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnBrowse" /> </Triggers> </asp:UpdatePanel>    <br /> </form> <script type="text/javascript" language="javascript"> var btnID = ""; Sys.WebForms.PageRequestManager.getInstance().add_beginRequest( function(sender,args){ btnID = args._postBackElement.id; } ); Sys.WebForms.PageRequestManager.getInstance().add_endRequest( function(sender, args){ if(btnID =="<%=btnBrowse.ClientID%>"){ $get("<%= btnPopTrigger.ClientID%>").click(); } } ); </script></body></html>
C# code modified.

Protected Sub btnBrowse_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = "updatepanel updated"
End Sub

Hope it helps.If I misunderstood you, please let me know.


Thanks Jonathan for your effort to help me. Actually my update panel and all the stuff works well. Here I will explain more.

I got a button, a panel, a text box. When the page is load, I will runtime looping create image button which I retrieve detail from database, I will runtime create another panel and table, which then everything will be populated to my present panel. This will will popup when clicked the button. The problem was, at my page load, I can see the panel during the population of my controls. The problem 'shows' too fast, couldn't have it capture to picture, below is the video I captured.

http://stephensaw.googlepages.com/ModalPopup.zip


Hi stephensaw,

Based on your description, I thinkmake your pnlPopup hide as default.

 <asp:Panel ID="pnlPopup" runat="server" Height="500px" Width="630px" BackColor="White"style="display:none"> </asp:Panel>
Hope it helps.

Hi stepensaw,

I have done some modifications based on your source code. And now we can select images without any postback and the implements moved to client side. Hope it will benefit our numbers.

Aspx:

<%@. Page Language="VB" AutoEventWireup="true" CodeFile="Default2.aspx.vb" Inherits="_Default2" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> if (window.screen) { this.moveTo(0, 0); this.resizeTo(screen.availWidth,screen.availHeight) } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="updateCollar" runat="server"> <ContentTemplate> Please select a collar design form our gallery:  <asp:TextBox ID="txtCode" runat="server"></asp:TextBox> <asp:Button ID="btnBrowse" runat="server" Text="Browse"/> <cc1:ModalPopupExtender ID="PopupCollar" runat="server" BackgroundCssClass="ModalPopupBackground" PopupControlID="pnlPopup" TargetControlID="btnBrowse"> </cc1:ModalPopupExtender> <asp:Panel ID="pnlPopup" runat="server" Height="500px" Width="630px" BackColor="white" style="display:none"> </asp:Panel>   </ContentTemplate> </asp:UpdatePanel>    <br /> </form> <script type="text/javascript" language="javascript"> function onSelectImage(imageID){ try{ $get("<%= txtCode.ClientID%>").value = imageID; $find("<%=PopupCollar.ClientID%>").hide(); return false } catch(e){ return false; } } </script></body></html>

VB.Net Code:

Imports System.Data.SqlClientImports System.Web.Services.webserviceImports System.DeploymentPartialClass _Default2Inherits System.Web.UI.Page'ConstantConst NUMPERCOLAs Integer = 4'Global VarDim conAs New SqlConnection("Server=localhost;Database=Wardrobe;Integrated Security=True")Dim comAs New SqlCommand()Dim drAs SqlDataReaderDim dsAs New Data.DataSetDim daAs New SqlDataAdapterDim dataRowsAs Data.DataRow()'Global ObjectDim imgButtonAs ImageButtonDim pnlAs PanelDim btnAs ButtonProtected Sub Page_Init(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Init com.Connection = con com.CommandText ="Select * From Collar" da.SelectCommand = comTry con.Open() da.Fill(ds,"Collar") dataRows = ds.Tables("Collar").Select()Catch exAs ExceptionFinally con.Close()End Try End Sub Private Sub populatePopupBox()Dim colCountAs Integer = 1Dim dataRowAs Data.DataRowDim tblAs New TableDim rowAs TableRowDim colAs TableCell'Generate Panel to populate with ImageButton pnl =New Panel pnl.ID ="pnlContent" pnl.BackColor = Drawing.Color.FromArgb(20, 49, 51, 163) pnl.Height =CType(pnlPopup.Height.Value - 20, Unit) pnl.Width = pnlPopup.Width pnl.HorizontalAlign = HorizontalAlign.Center pnl.ScrollBars = ScrollBars.Vertical'Prepare table structure tbl.ID ="tblCollar" tbl.Width =CType(pnl.Width.Value - 100, Unit) tbl.CellSpacing = 5 tbl.CellPadding = 5 row =New TableRowFor Each dataRowIn dataRowsIf colCount > NUMPERCOLThen tbl.Rows.Add(row) row =New TableRow colCount = 1End If col =New TableCell col.HorizontalAlign = HorizontalAlign.Center col.VerticalAlign = VerticalAlign.Middle col.Attributes.Add("onmouseover","this.style.backgroundColor='#E9ECEF';") col.Attributes.Add("onmouseout", "this.style.backgroundColor='';")If txtCode.Text = dataRow("col_Code").ToStringThen col.BackColor = Drawing.Color.FromArgb(100, 233, 236, 239)End If imgButton =New ImageButton imgButton.ID = dataRow("col_Code").ToString imgButton.ImageUrl ="collar/" & dataRow("col_Picture").ToString imgButton.Width = 100 imgButton.Height = 100 imgButton.OnClientClick ="return onSelectImage('" + dataRow("col_Code").ToString + "');" col.Controls.Add(imgButton) row.Cells.Add(col) colCount += 1 Next tbl.Rows.Add(row) pnl.Controls.Add(tbl) btn = New Button btn.ID = "btnCancel" btn.Text = "Cancel" PopupCollar.CancelControlID = btn.ID pnlPopup.Controls.Add(pnl) pnlPopup.Controls.Add(btn)End Sub Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not IsPostBackThen populatePopupBox()End If End SubEnd Class

Hope it helps.

Wednesday, March 21, 2012

ParserErrorException when Edit button on Datagrid pressed

I have a datagrid control wrapped in an UpdatePanel. There are Edit/Delete ImageButton's for each row. The first time I press the Edit butonn (setsEditItemIndex = -1) the ubiquitous Sys.Webforms.PageRequestManagerParserErrorException; The message from the server could not be parsed...

Subsequently, pressing the edit button prooduces the desired results.

Any ideas with this strange behavior are appreciated.

TIA

Hi,

Please refer to this:http://siderite.blogspot.com/2007/02/aspnet-ajax-and-responsewrite-or.html

It gives a full explanation of it. Hope this helps.

NOTE:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


I also face this kind of problem - 'Sys.WebForms.PageRequestManagerPerserErrorException:'. So far I
understand this happen when there is some unrecongnize html render or event occurs. I'm also not very clear.

But I solve the issue by set the attribute EnableEventValidation="false" in the ASPX page, where I place my
UpdatePanel.

Thanks
I also face this kind of problem - 'Sys.WebForms.PageRequestManagerPerserErrorException:'. So far I
understand this happen when there is some unrecongnize html render or event occurs. I'm also not very clear.

But I solve the issue by set the attribute EnableEventValidation="false" in the ASPX page, where I place my
UpdatePanel.

Thanks

partial postback doing full postback - bug in ATLAS ?

theres no rhyme or reason, but my partial postback button often does full postbacks and then reverts to partial postbacks for no apparent reason...

I can't find anything on this and was suggested that this is a bug in the current release of ATLAS. Does anyone have any idea on this ?

I'm bashing my head trying to figure this one out ..


Thanks very much

mike123

hello.

well, that is strange. do you have a simple demo page that reproduces this?


I'm sorry I don't have one at this time ... =[ I could get it online if you think its crucial to see it to help diagnose

any ideas ?

thanks very much


well, we have to see the server side code to help you diagnoise. an online sample doesn't give us that.


The actual code doesnt really show too much but here it is anyways

I'm really lost on where to go from here. Anyone have any ideas ? I was so psyched about using ATLAS but it's pretty frustrating not being able to get past this point.

Thanks again,

mike123

<formid="form1"runat="server">

<asp:TextBoxId="textbox1"runat="server"/>

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<divstyle="background-color: Yellow; float: left; width: 100px;">

<asp:LabelID="FullPostBackLabel"runat="server"/><br/>

<asp:ButtonID="FullPostBackButton"runat="server"text="Full Post Back"OnClick="FullPostBackButton_OnClick"/>

</div>

<atlas:UpdatePanelrunat="server"ID="UpdatePanel1"Mode="Conditional">

<ContentTemplate>

<divstyle="background-color: Lime; width: 100px;">

<asp:LabelID="PartialPostBackLabel"runat="server"/><br/>

<asp:ButtonID="PartialPostBackButton"runat="server"text="Partial Post Back"OnClick="PartialPostBackButton_OnClick"/>

</div>

</ContentTemplate>

</atlas:UpdatePanel>

<atlas:UpdateProgressID="UpdateProgress1"runat="server">

<ProgressTemplate>

Please wait... </ProgressTemplate>

</atlas:UpdateProgress>

</form>

PublicSub FullPostBackButton_OnClick(ByVal senderAsObject,ByVal eAs EventArgs)

FullPostBackLabel.Text = DateTime.Now.ToString()

EndSub

PublicSub PartialPostBackButton_OnClick(ByVal senderAsObject,ByVal eAs EventArgs)

PartialPostBackLabel.Text = DateTime.Now.ToString() &"Partial"

EndSub


hello.

this is weird. i tried running your page in an empty atlas site and it worked without anyproblems...have you tried running this page in a site created through the atlas template?


No I haven't as this is a pretty large web application that needs to have atlas running on it. I don't think theres a problem with the code either, something to do with integration but no idea where to start. I've tried things such as removing flash from the page and javascript ads.... Still no luck ....

Any ideas?

Thanks very much

mike123


I had a similar problem then I found that it was related to custom javascript code that was calling __dopostback


I had a smiliar problem too. I found that It didnt like my hidden input.

<input type="hidden" name="action" ID="action" value="" />

Once i deleted that everything was fine!


I found out that when removing the following line

<xhtmlConformance mode="Legacy"/>

from web.config , UpdatePanels work like they should

this did not occur in Atlas CTPs, but in AJAX final release...

partial postback does not occur but the whole page gets reloaded


Hello coders,

I got a problem with my updatepanel.
I have a dynamic datagrid with a delete button. When i press the delete button
the partial postback occurs. ALL THIS WORKS FINE.

However i also have a Textbox in the same datagrid.
When i change the value in the Textbox a callback is generated.
The partial postback does not occur but the whole page gets reloaded.
This is not what i want.

So what is the diference between these two?

I will post a simplified version of my code:

'------<asp:UpdatePanel ID="udpWinkelwagen" runat="server"> <ContentTemplate> <asp:PlaceHolder ID="phWinkelwagen" runat="server" ></asp:PlaceHolder> </ContentTemplate></asp:UpdatePanel>'------ dgWinkelwagen =New DataGrid dgWinkelwagen.AutoGenerateColumns =False dgWinkelwagen.ShowFooter =True dgWinkelwagen.DataSource = ds.Tables(0) ...'TextField tempCol =New TemplateColumn tempCol.HeaderText = myDB.LeesVeld(myDB.haalViewOp("web_WinkelwagenText","quantity", taal),"Text") tempCol.ItemTemplate =New DynamicItemTemplateTextBox(Me.Page, bestelnr, taal) dgWinkelwagen.Columns.Add(tempCol)'delete button strConrirm = myDB.LeesVeld(myDB.haalViewOp("web_WinkelwagenText","confirmDelete", taal),"omschrijving") tempCol =New TemplateColumn tempCol.ItemStyle.HorizontalAlign = HorizontalAlign.Center tempCol.HeaderText ="" tempCol.ItemTemplate =New DynamicItemTemplateDeleteButton(bestelnr, strConrirm,Me.Page) dgWinkelwagen.Columns.Add(tempCol) dgWinkelwagen.DataBind()' add to placeholder on page phWinkelwagen.Controls.Add(dgWinkelwagen)'------Public Class DynamicItemTemplateTextBoxImplements ITemplateDim ds, dsProcAs DataSetDim myDBAs DB =New DBDim myHulpAs HulpFuncties =New HulpFunctiesDim myOrbisAs OrbisTaskCentre =New OrbisTaskCentreDim myWebshopAs webshopFuncties =New webshopFunctiesDim taalAs String Dim btnSave, txtSave, strAlert, titel, omschrijvingAs String Dim artikel, bestelnr, errorTextAs String Dim myPageAs PageDim aantalAs Double Sub New(ByVal pAs Page,ByVal bestnrAs String,ByVal taalcodeAs String) myPage = p bestelnr = bestnr taal = taalcodeEnd Sub Public Sub InstantiateIn(ByVal containerAs Control)Implements ITemplate.InstantiateInDim txtAantalAs TextBox =New TextBox() txtAantal.AutoPostBack =True txtAantal.Width ="38" txtAantal.MaxLength ="4"AddHandler txtAantal.TextChanged,AddressOf Me.changeValue container.Controls.Add(txtAantal)End Sub Public Sub changeValue(ByVal senderAs Object,ByVal eAs EventArgs)CType(myPage.Master, masterMethods).updateCart()CType(myPage.Page, winkelwagenMethods).updateGrid()End SubEnd Class'------Public Class DynamicItemTemplateDeleteButtonImplements ITemplateDim artnr, txtAantal, btnDelete, strConfirm, omschrijving, strAlertAs String Dim myDbAs DB =New DBDim dsProcAs DataSetDim bestelnrAs Integer Dim mypageAs PageSub New(ByVal _bestelnrAs Integer,ByVal confirmAs String,ByVal _pageAs Page) strConfirm = confirm bestelnr = _bestelnr mypage = _pageEnd Sub Public Sub InstantiateIn(ByVal containerAs Control)Implements ITemplate.InstantiateInDim imgBtnDelAs ImageButton =New ImageButton() imgBtnDel.ImageUrl ="~/images/remove.gif"AddHandler imgBtnDel.Click,AddressOf Me.DeleteArtikel container.Controls.Add(imgBtnDel)End Sub Public Sub DeleteArtikel(ByVal senderAs Object,ByVal eAs ImageClickEventArgs) artnr =CType(CType(sender, ImageButton).Parent.Parent.Controls(1).Controls(0), Label).TextDim parameters1()As String = {bestelnr, artnr} dsProc = myDb.startProcedure("web_winkelwagen_artikel_delete", parameters1)CType(mypage.Master, masterMethods).updateCart()CType(mypage.Page, winkelwagenMethods).updateGrid()End SubEnd Class

hello.

can you builkd a simple demo page that reproduces the app and put it here so that we can simply copy/paste it into vs?