Showing posts with label updatepanel. Show all posts
Showing posts with label updatepanel. Show all posts

Wednesday, March 28, 2012

Accessing the PageRequestManager when Page is iFramed

I have a page that has a scriptmanager, updatepanel, and timer in it. This page is iframed by another page on another domain. I'm trying to override what happens when the update panel / asynch post back has an error like so:

<scripttype="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest( endRequest );
function endRequest( sender, e ) {
if( e.get_error() ){
}
}
</script>

Per Luis' post here:http://msmvps.com/blogs/luisabreu/archive/2006/10/29/UpdatePanel_3A00_-having-fun-with-errors.aspx

This seems to work fine but when the page is iframed in i get the following javascript error:

'Sys' is undefined.

Any ideas on how to fix this?

Thanks

Hi,chris.risner

I am afraid we cannot find out the exact root cause without further information captured when the problem occurs.

But please follow this link on the main page of thehttp://weblogs.asp.net, I see that this is well explained:

Demystifying 'Sys is undefined' :http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx

You can also check this link for more help ifyou're using IIS7:

Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7 :http://geekswithblogs.net/lorint/archive/2007/03/28/110161.aspx

Let me know if you have further questions on this,

If this help you,don't forget mark it as a answer.Thanks!

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.

Accessing objects in an UpdatePanel

I'm trying to reference a textbox that is located in an updatepanel and was successfully doing so until I installed the latest version of the CTP (Sept 2006) and now I don't have programmatic access to the objects in the update panel...how can I get to this? Below is my same code that worked in the last version:

<divid="footer">
<atlas:UpdatePanelID="udpStatusBar"runat="server"Mode="Always">
<ContentTemplate>
<asp:TextBoxID="tbxStatusMessage"runat="server"Enabled="False"SkinID="StatusBar"Width="455px"></asp:TextBox>
<asp:TextBoxID="tbxStats"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
<asp:TextBoxID="tbxDate"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
</ContentTemplate>
</atlas:UpdatePanel>
</div>

ASPX.cs

privatevoid DisplayMessage(string s)
{
((TextBox)this.Parent.Page.Master.Controls[3].FindControl("tbxStatusMessage")).Text = s;
}

myost2921:

I'm trying to reference a textbox that is located in an updatepanel and was successfully doing so until I installed the latest version of the CTP (Sept 2006) and now I don't have programmatic access to the objects in the update panel...how can I get to this? Below is my same code that worked in the last version:

<divid="footer">
<atlas:UpdatePanelID="udpStatusBar"runat="server"Mode="Always">
<ContentTemplate>
<asp:TextBoxID="tbxStatusMessage"runat="server"Enabled="False"SkinID="StatusBar"Width="455px"></asp:TextBox>
<asp:TextBoxID="tbxStats"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
<asp:TextBoxID="tbxDate"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
</ContentTemplate>
</atlas:UpdatePanel>
</div>

ASPX.cs

privatevoid DisplayMessage(string s)
{
((TextBox)this.Parent.Page.Master.Controls[3].FindControl("tbxStatusMessage")).Text = s;
}

You should be able to access the control directly. This should work for your DisplayMessage function:

tbxStatusMessage.Text = s;

The problem is that my DisplayMessage is sitting in a UserControl that is loaded dynamically into the page. The UserControl knows nothing of the page until runtime.
The problem is that the DisplayMessage method is found in a UserControl which is being dynamically added to the page at runtime. I'm having to use the FindControl command because of that reason. Any more ideas?

What error are you getting? Have you tried just calling page.findcontrol()?

A quick example:

.aspx file:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="wizard_validation.aspx.vb" Inherits="wizard_validation" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="act" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <atlas:ScriptManager runat="server" ID="blah2" EnablePartialRendering="true"></atlas:ScriptManager> <atlas:UpdatePanel runat="server" ID="blah" Mode="conditional"> <ContentTemplate> <asp:Wizard ID="NewFormWizard" runat="server" Width="100%" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" CancelButtonText="Cancel" DisplayCancelButton="true" > <WizardSteps> <asp:TemplatedWizardStep ID="WizardStepGeneral" runat="server" Title="*General"> <ContentTemplate> <h1>Header!</h1> </ContentTemplate> </asp:TemplatedWizardStep> </WizardSteps> </asp:Wizard> </ContentTemplate> </atlas:UpdatePanel> </div> </form></body></html>

Code-behind (in VB, but I'm sure you can figure it out):

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadDim iAs Integer Dim tmpwizardAs Wizard tmpwizard = Page.FindControl("NewFormWizard")If tmpwizardIs Nothing Then' failure i = 0Else' success i = 1End If End Sub

It returns with a success on that sample page. However, this is not a dynamically added control, so if you could post an example if using "Page.FindControl" doesn't work, it'd be easier to help ya out.


I figured out the problem...turns out it was actually simplified even more in this release and the cause of the error was something completely different. Thanks Matt!

Accessing DropDownList in UpdatePanel programmatically

I have an updatepanel within and updatepanel and am trying to access a drop down list as shown below. I am receiving an error saying the object is not set.

Dim LOAN_TYPEAs DropDownList =New DropDownList

LOAN_TYPE = UpdatePanel1.FindControl("UpdatePanel2").FindControl("ddlSIM_TYPE")

If LOAN_TYPE.SelectedValue ="Std"Then 'THIS IS WHERE I RECEIVE MY ERROR

Any ideas?

Try:

Dim LOAN_TYPEAs DropDownList = CType(UpdatePanel1.FindControl("UpdatePanel2").FindControl("ddlSIM_TYPE") , DropDownList)

-Damien


I tried that as well and same message. This is driving me nuts...

Any other ideas? Thanks for your help!


Use UpdatePanel.ContentTemplateContainer.FindControl(), instead.


You are going to hate me but that resulted in the same error message.

UpdatePanel1.ContentTemplateContainer.FindControl("UpdatePanel2").FindControl("ddlSIM_TYPE")


You need to use it on both UpdatePanels. In C#, it would work like this:

UpdatePanel up2 = (UpdatePanel)UpdatePanel1.ContentTemplateContainer.FindControl("UpdatePanel2");
DropDownList ddl = (DropDownList)up2.ContentTemplateContainer.FindControl("ddlSIM_TYPE");

I'm not sure of the exact VB syntax, but hopefully that makes sense.

Though, unless UpdatePanel2 is dynamically generated, you ought to be able to just find the dropdown like this:

DropDownList ddl = (DropDownList)UpdatePanel2.ContentTemplate.FindControl("ddlSIM_TYPE");

Ok, tried that and no luck. Here is the code section:

Dim p2As UpdatePanel = UpdatePanel1.ContentTemplateContainer.FindControl("UpdatePanel2")

Dim PVAs TextBox = p2.ContentTemplateContainer.FindControl("txtSIM_PV")

Dim IAs TextBox = p2.ContentTemplateContainer.FindControl("txtSIM_I")

Dim NAs TextBox = p2.ContentTemplateContainer.FindControl("txtSIM_N")

Dim LOAN_TYPEAs DropDownList = p2.ContentTemplateContainer.FindControl("ddlSIM_TYPE")

If LOAN_TYPE.SelectedValue ="Std"Then

When accessing this if statement i get an object not set error when accessing any of the objects shown above. I have checked and double checked everything and no luck. its inside the Form tag, it has runat=server, etc. Any other ideas - I am at my wits end...

Thanks


Well on the bright side, if you're not getting the error until the conditional, that means the UpdatePanel2 find is working.

Inside UpdatePanel2, are your TextBox and DropDownList controls contained within another control, like a panel or a wizard or a repeater?


Hi,

I agree withgt1329a.

But seeSolution to the FindControl problem for more information about FindControl problem.

Best Regards,

Accessing controls within an Accordion for UpdatePanel triggers

HI All,

I have an accordion control, which contains a treeview control in one of its panels. I would like to use some of the events for that treeview control as a trigger for an update panel on the same page. Works fine without the Accordion, but when I use the Accordion, I receive an error notifying me that the treeview doesnt exist (I assume because the Accordion control hides it from the source engine).

Any thoughts on how to get around this?

Thanks

Rob

Hey,

I find that I run into this alot. Basically when you have a template control, then the child controls aren't directly accessible from the code behind. Instead you need to get the parent control and call parent.FindControl("name"). Then use this instance to make changes. If this doesn't work or make sense, post an example.

Accessing Controls outside Update Panel.

Hello,

I am having a webapplication in which i am having two pages. w1.aspx and popup.aspx,

On w1.aspx I am having a Menu control and a UpdatePanel control (Ajax Control) and then under Update panel i am having a link named SigIN and a button named refresh,On the click of SignIN l;ink the popup.aspx opens which provides functionality to signin , On that popup window i am logging user in using ajax so there is no refresh in that popup when user signing in.

Now after user signin succefully from the popup.aspx page that is a popup window i am displaying a messge to the user there that "You are SignIN succesfully and now close this window"

When user close the popup window then user comes on the w1.aspx , Now i want when user press the Button Refresh that is present on the w1.aspx under updatepanel control.. then the text of first menu item in the menu control that is present on the page w1.aspx but not under updatepanel will be changed from SignIN to SignOUT, and the link label that is present on this page under updatepanel will be hidden after the click of this refresh button,

But the problem is on the click of this refresh button the link will be hidden but the text of the menu item is not changing. That is i am not able to acces the controls that are present outside the updatepanel control.

WHY??

is it possible to acces the control properties present outside the UpdatePanel control on the click of a button that is present under UpdatePanel control.

????????

Hi, you must to place any control that an another control on UpdatePanel changes on another UpdatePanel. Controls on UpdatePanel can′t to change controls outside UpdatePanel (Don′t happens an error, just don′t works). Don′t need to be the same UpdatePanel. Can be another one, but must be inside of UpdatePanel.


Hi mgodoy_desenv,

Can u please provide me a sample code for the same.

Thanks in Advance...


My codes are very big, so I will to try show. I don′t speak English so much, so excusive for my way of writing:

In code below, you have a control inside UpdatePanel and another one outside:

<html>
...
<asp: Textbox ID="Textbox1" runat="server"/>
...
<asp: UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"/>
</ContentTemplate>
</asp: UpdatePanel>
</html
To Button1 to change the Text property of Textbox1, Textbox1 must to be placed inside of an UpdatePanel. You not will have an error if that don′t to happen. Just don′t works.

To work, the Textbox1 must be a place inside of an UpdatePanel. The good news is that it don′t need be inside of same UpdatePanel. It can be placed inside another one.

The code below corrects the problem:

<html>
...
<asp: UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>

<asp: Textbox ID="Textbox1" runat="server"/>
</ContentTemplate>
</asp: UpdatePanel>

...
<asp: UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"/>
</ContentTemplate>
</asp: UpdatePanel>
</html>


Hi,

Your idea is working for a single page but when i am working with master page and menu then i think its not working properly.

Wht i am doing is,

I am having a webpage w1.aspx which is using the master page m1.master, Now my master page having a menu. I want to update the value of that page from the w1.aspx on the click of a button that is present under an updatepanel on w1.aspx.

Now as you said take the control inside the update panel whose value you wann update, so i have taken the menu control under the update panel and then by taking the refrence of menu control on the page w1.aspx i am updating the value of the menu items. But after updatiing the values when i am moving the mouse over the menu items then it gives me the error. some javascript error. I d't know why this ?

If u can then try to do the same thing as i said... with master page..and menu contriol

....


There are many problems with use of UpdatePanel. We must be carefully with it, cause asynchronous post back uses many JavaScript. I haved, for example, many problems with Server.Transfer and UpdatePanel.

Your case isn′t diferent. UpdatePanel can has updated the menu control in a wrong way. Try do this:

1. Use a DataSource to menu. Create a method to populate it with a DataTable, or Xml.
2. When you to want to change items of menu control, change the DataSource (DataTable, or Xml) and call DataBind method of menu.

I don′t speak English so much. So, excuse me for my way of writing.


The Menu control is one of the few ASP.NET controls that isnot compatible with async postbacks. Seehttp://asp.net/AJAX/Documentation/Live/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls for reference.

I would think you should leave the Menu controloutside of the UpdatePanel, but make it a trigger for the UpdatePanel you want to update with <asp:UpdatePanel ...><Triggers><asp:AsyncPostBackTrigger ControlID="MyMenu" /></Triggers>...</asp:UpdatePanel>.


Actually, rereading the question, I may have missed the point here... I was assuming the Menu control was the one triggering the update, but that some other control on the page was being updated.

If the Menu control is the one you want to update, I think you're out of luck, since the Menu can't live inside an UpdatePanel.

Accessing controls inside an updatepanel in onPreInit event

I have an update panel inside a user control that is initialized during the page's PreInit event. However, as soon as I put an updatepanel inside this user control I can no longer access the controls inside this updatepanel during the PreInit event. The controls are all just "null". Am I doing something wrong, or does the updatepanel somehow change my ability to access these controls?Thanks,Jon

Set a breakpoint in PreInit and step through the PageLifeCycle then you see in what Event the UpdatePanel get initialized.


I was just wondering why putting an updatepanel in would break my existing code? Shouldn't it get initialized at the same time as the other controls?
Please have a look at Wally'sPodcast about the clientside lifecycle. I think he's awnsering youre questions.

accessing controls from diff updatepanels

Hi

Just wondering is it possible to access controls from diff update panels

I have a treeview in 1 updatepanel, upon selecting a node in the tree I want to display a panel outside the updatepanel, possibly in another updatepanel

confusing? maybe

Dim panel1 As Panel = CType(Me.UpdatePanel1.FindControl("panel10"), Panel)

Panel1.Visible = True

It definately finds the contro, but will not mae it visible

thoughts ?

Hi!

Are you calling UpdatePanel1.Update() after you set the visible property to true? If you are missing that the Panel will be "visible" but not "showing" as visible.

Also, just a doubt: Why you need to use FindControl to find controls inside UpdatePanels? They aren't NamingContainers, thus you should be able to call them directly from the page.

Regards,

Juan


One more note: if you're talking about using a TreeView, note that the TreeView control isn't compatible with partial rendering (so it can't get updated inside an UpdatePanel). Seehttp://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls.

A good way to think about the UpdatePanel is that it doesn't really change the way postbacks work. So if you can do what you want to with a regular postback, then it should just be a matter of wrapping the write regions of the page in UpdatePanels and setting up the triggers (or calling UpdatePanel1.Update() in the code-behind) to make sure those regions of the page get updated when appropriate during the async postback. My advice would be to get this working how you want with regular postbacks, then add UpdatePanels (which will by default all update on every async postback), and finally optimize by setting UpdateMode="Conditional" and setting up your triggers, so you selectively update the parts of the page that you need to.


thanks guys , some great advice there

UpdatePanel1.Update() was the key here


Steve Marx:

One more note: if you're talking about using a TreeView, note that the TreeView control isn't compatible with partial rendering (so it can't get updated inside an UpdatePanel). Seehttp://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls.

Steve , Is this something that will be fixed in future AJAX releases

I also have some file upload controls on the page that I really need to have there

Monday, March 26, 2012

Accessibility and the UpdatePanel

Hi,

What's the latest info on accessibility and the UpdatePanel. Can screen readers handle async updates using the UpdatePanel?

Many thanks

Mat

Hi Matg,

Yes. Here the is the tutorials about Update. Hope it helps.

http://ajax.asp.net/docs/tutorials/UpdatePanelTutorials.aspx

If any problems ,please let me know!

Access Updatepanel using masterpage

Hi,

Quick scenario... Simple shop with a masterpage, and thus contentpages. On the masterpage I have an updatepanel which is to act as my basket...

Masterpage:

....

<asp:UpdatePanelID="BasketUpdatePanel"runat="server">

<ContentTemplate>

<asp:TableID="BasketTable"runat="server">

<asp:TableRow>

<asp:TableCell>

<asp:LabelID="BasketHeaderLabel"runat="server"Text="Basket"></asp:Label>

</asp:TableCell>

</asp:TableRow>

<asp:TableRow>

<asp:TableCell>

<asp:Labelrunat="server"Text="0"ID="amountControl"></asp:Label>

</asp:TableCell>

</asp:TableRow>

</asp:Table>

</ContentTemplate>

</asp:UpdatePanel>

.....

On my content page I am dynamically adding items for the shop, and a button to add the item to the basket, this including adding a trigger for each button and adding this to the triggercollection of the updatepanel for my basket..

UpdatePanel basketUpdatePanel = (UpdatePanel)this.Master.FindControl("BasketUpdatePanel");
AsyncPostBackTrigger trigger =newAsyncPostBackTrigger();
trigger.ControlID ="amountControl";
trigger.EventName ="Click";
basketUpdatePanel.Triggers.Add(trigger);

No compilation errors but the following error when the page is rendered:

Control with ID 'amountControl' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler.

Help..

Dannv

dannv:

Control with ID 'amountControl' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler.

This error means, you can add only controls to the triggercollection they are able to rise an event. A label, like in your situation, could'nt rise any event.


You are rigth, and this of course makes perfectly sense...

I changed the controlid to

trigger.ControlID = basketButton.ID;

Which is the button where the event is fired from...

Clicking the botton, now fires a postback, but does not activate my click method.. any obvious suggestions...??


dannv:

Clicking the botton, now fires a postback, but does not activate my click method.. any obvious suggestions...??

you've the click method assigned as the click event to the button eg. OnClick="basketButton_Click" for serverside handling or OnClientClick="JavaScriptFunction()" for clientside JavaScript?


It is set to serverside handling, using the OnClick event...


dannv:

Clicking the botton, now fires a postback, but does not activate my click method..

Not realy sure what you mean. The workflow should be: the UpdatePanel has basketButtons ClickEvent as a trigger. If the basketButton fire his ClickEvent, the UpdatePanel is triggered and initialize a partial page update from his content. So what you mean with:but does not activate my click method ? Is the updatepanel not updating? get you any error? if so, which error you get?


Sorry for wasting your time on the last issue... just retested and now it works...Devil

But thanks for your help and patience

Dann

Access to ScriptManager from into webcontrol

Hi, I've a UpdatePanel into my personal webcontrol, and one scriptmanager what can be into webform, into master page, or into content page.
I need have access to ScriptManager from a method of my personal web control. Is it possible?

Hi,

yes it is. You can call System.Web.UI.ScriptManager.GetCurrent(this.Page) to retrieve a reference to the ScriptManager control.


Thank you Garbin!!!!!, it's wonderful!!!!!

Greetings, Diego

Access credentials are not being loaded when use Atlas functionality

Facing this bizzare issue of access denied when use Atlas funcationality. I am using UpdatePanel in two .ascx controls that searches a list(list is on one .ascx and search button is on the 2nd .ascx).Everything works fine(i.e performs search in an Atlas way - no whol page refresh) but it generates an error on the browser that says..

A run time error has occured..

Line: 86762781

Error: Object expected.

When i see the log file at c:/windows/system32/Logfiles/ W3SVC1.. i see

That request is using 127.0.0.1 as the credentials instead of my own credential string.

This is the case if i use Atlas UpdatePanel otherwise it works fine.

Any clue in this regards, do i have to do something in terms of security to get it working?

Copied this Microsoft.Web.Atlas.dll over to my machine and issue went away.

Access controls added dinamically?

Hi:
I trying to access to controls in updatepanel that I createddinamically before with atlas too, and I allways get the error that thecontrol does not exist.
Is there any way to do this?
Thanks so much.Do you have some sample source you can post? In which event handler are you trying to access the controls?
I was tried this with the code in the examples section. With SimpleList1_edit.aspx exactly.
I add a new textbox and a new button to panel3 when I click button ,and it works perfect, but when I click the new button and go to thecode for the code onclick then the findcontrol never finds the controlin the panel. I tried with find in the whole page and only in the panel and never works. This is the code:

<%@. Page Language="C#" %>

<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
TimerMessage.Text = DateTime.Now.ToLongTimeString();
if (!IsPostBack)
{
ViewState["CurrentTab"] = "0";
}
}


protected void AddnewBtn_click2(object sender, EventArgs e)
{
TextBox txtbox = (TextBox)FindControl("newtxtbox");
idlbl.Text = txtbox.Text;
panel3.Update();
}
protected void AddnewBtn_click(object sender, EventArgs e)
{


TextBox txtbox = new TextBox();
txtbox.ID = "newtxtbox";
Button btn = new Button();
btn.ID = "newbtn";
btn.OnClientClick = "AddnewBtn_click2";
panel3.Controls.Add(txtbox);
panel3.Controls.Add(btn);
btn.Text = "Read new textbox value";
panel3.Update();

}
protected string FormatPriority(int priority)
{
switch (priority)
{
case 1:
return "Low";
case 2:
return "Medium";
default:
return "High";
}
}

protected string FormatDone(bool isDone)
{
return isDone == true ? "Yes" : "No";
}

protected void Done_CheckedChanged(object sender, EventArgs e)
{
CheckBox cbx = (CheckBox)sender;
GridViewRow row = (GridViewRow)cbx.NamingContainer;
using (SqlConnection cn =newSqlConnection(ConfigurationManager.ConnectionStrings["SimpleListsConnectionString"].ConnectionString))
{
cn.Open();
SqlCommand cmd = new SqlCommand(
"UPDATE Lists SET IsComplete = @.IsComplete WHERE ListId = @.ListId",cn);
cmd.Parameters.Add("IsComplete", cbx.Checked);
cmd.Parameters.Add("ListId", ListGrid.DataKeys[row.RowIndex].Value);
cmd.ExecuteNonQuery();
}
ListGrid.DataBind();
}

protected void Select_Command(object sender, CommandEventArgs e)
{
ListDataSource.SelectParameters["IsComplete"].DefaultValue =
e.CommandArgument.ToString();
if (e.CommandName == "show")
SearchText.Text = "";
ViewState["CurrentTab"] = e.CommandArgument;
panel2.Update();
}

protected void Page_PreRender(object sender, EventArgs e)
{
int i = int.Parse(ViewState["CurrentTab"].ToString());
ActiveButton.CssClass = i == 0 ? "activeTab" : "tab";
CompletedButton.CssClass = i == 1 ? "activeTab" : "tab";
AllButton.CssClass = i == -1 ? "activeTab" : "tab";
SearchTab.Attributes["class"] = i == -2 ? "activeTab" : "tab";
}
protected void Page_ErrorHandler(object sender, PageErrorEventArgs e)
{
e.ErrorMessage = "Exception at " + DateTime.Now.ToString() +
"; Error Message: " + e.Error.Message;
}

</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<link href="http://links.10026.com/?link=StyleSheet.css" rel="stylesheet" type="text/css" />
<title>Partial Rendering</title>


</head>
<body>
<form id="f1" runat="server">
<atlas:ScriptManagerID="ScriptManager1" EnablePartialRendering="true"OnPageError="Page_ErrorHandler" runat="server">
<ErrorTemplate>
<div style="width: 450px; height: 300px; padding: 10px; border:solid 3px black; background: #ffd; text-align: left;">
<h1>Server Error</h1>
<p>An unhandled exception with the following message has occuredon the server:</p>
<p><span id="errorMessageLabel"runat="server"></span></p>
<p><input id="okButton" type="button" value="OK"runat="server"/></p>
</div>
</ErrorTemplate>
</atlas:ScriptManager>
<atlas:UpdateProgress runat="server" id="updateProgress1">
<ProgressTemplate>
<div style="width: 450px; height:300px;position:absolute; padding: 10px; border: solid 3px black;background: #ffd; text-align: left;">
<img src="http://pics.10026.com/?src=Progress.gif" /> Contacting Server...
<button id="abortButton">Stop</button>
</div>
</ProgressTemplate>
</atlas:UpdateProgress>
<div>
<div id="top">

</div>
<div class="ContentContainer">
<div id="header">
<div id="ServerMessage">
<span class="controlLabel">Server Time:</span>
<asp:Label ID="TimerMessage" runat="server">n/a</asp:Label><asp:Button ID="UpdateTimerMessageBtn" Text="Update" runat="server"/>
</div>
<span class="title"><a href="http://links.10026.com/?link=Default.aspx">SimpleList</a> > Standard Server Page</span>
</div>
<div class="tabs">

<atlas:UpdatePanel ID="panel1" runat="serveR" Mode="Conditional">
<ContentTemplate>
<span class="controlLabel">Show:</span>
<asp:LinkButton ID="ActiveButton" Text="Active" CommandName="show"CommandArgument="0" OnCommand="Select_Command" runat="server" />
<asp:LinkButton ID="CompletedButton" Text="Completed"CommandName="show" CommandArgument="1" OnCommand="Select_Command"runat="server" />
<asp:LinkButton ID="AllButton" Text="All" CommandName="show"CommandArgument="-1" OnCommand="Select_Command" runat="server" />
<span class="controlLabel leftSpace">Search:</span>
<span id="SearchTab" runat="server">
<asp:TextBox ID="SearchText" CssClass="filterdropdown" Width="150px"runat="server" />
<asp:Button ID="SearchBtn" CssClass="topButtons" Text=" >> "
CommandName="search" CommandArgument="-2" OnCommand="Select_Command"runat="server" />
</span>
</ContentTemplate>
</atlas:UpdatePanel>
<!-- Add a closing UpdatePanel tag below here. -->
</div>
<div id="list">

<atlas:UpdatePanel ID="panel2" runat="server" Mode="Conditional">
<ContentTemplate>
<asp:GridView ID="ListGrid" BorderWidth="0px"AutoGenerateColumns="False" DataKeyNames="ListId"
DataSourceID="ListDataSource" AllowPaging="True" AllowSorting="True"EnableViewState="False"
GridLines="None" runat="server">
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server"CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="DeleteBtn" runat="server"CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
<ControlStyle CssClass="buttons" />
<HeaderStyle CssClass="commands" />
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="List"SortExpression="Name">
<ControlStyle CssClass="name_edit" />
<ItemStyle CssClass="name" />
<HeaderStyle CssClass="name" />
</asp:BoundField>
<asp:TemplateField HeaderText="Priority"SortExpression="Priority">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" Width="75"SelectedValue='<%# Bind("Priority") %>'
runat="server">
<asp:ListItem Text="High" Value="3" />
<asp:ListItem Text="Medium" Value="2" />
<asp:ListItem Text="Low" Value="1" />
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="pri" Text='<%# FormatPriority((int)Eval("Priority")) %>' runat="server" />
</ItemTemplate>
<ItemStyle CssClass="priority" />
<HeaderStyle CssClass="priority" />
</asp:TemplateField>
<asp:BoundField DataField="DateCreated"DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="False"
HeaderText="Started" ReadOnly="True" SortExpression="DateCreated">
<ItemStyle CssClass="started" />
<HeaderStyle CssClass="started" />
</asp:BoundField>
<asp:TemplateField HeaderText="Completed"SortExpression="IsComplete">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#Bind("IsComplete") %>' />
</EditItemTemplate>
<ItemStyle CssClass="iscomplete" />
<HeaderStyle CssClass="iscomplete" />
<ItemTemplate>
<asp:Label ID="Done" Text='<%# FormatDone((bool)Eval("IsComplete")) %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<span id="Empty">No lists</span>
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="AddListBtn" EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>
<!-- Add a closing UpdatePanel tag below here. -->
</div>
<div id="AddNew">

<atlas:UpdatePanel ID="panel3" Mode="Conditional" runat="server">
<ContentTemplate>
<span>Add New List:</span>
<asp:TextBox ID="AddItemTxt" CssClass="newitem"runat="server"></asp:TextBox>
<asp:Button ID="AddnewBtn" runat="server" OnClick="AddnewBtn_Click"Text="Add" />
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="AddnewBtn" EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>

</div>


</div>
</div>

<asp:SqlDataSourceID="ListDataSource" runat="server" ConnectionString="<%$ConnectionStrings:SimpleListsConnectionString %>"
SelectCommand="SELECT ListId, Name, Priority, IsComplete, DateCreated
FROM Lists
WHERE (@.IsComplete = -1)
OR (@.IsComplete in (0, 1) AND IsComplete = @.IsComplete)
OR (@.IsComplete = -2 AND Name LIKE '%' + @.SearchText + '%')"
UpdateCommand="UPDATE Lists
SET Name=@.Name, IsComplete=@.IsComplete, Priority=@.Priority
WHERE ListId = @.ListId"
DeleteCommand="DELETE FROM Lists WHERE ListId = @.ListId">
<SelectParameters>
<asp:Parameter Name="IsComplete" Type="Int32" DefaultValue="0" />
<asp:ControlParameter Name="SearchText" Type="string"ControlID="SearchText"
PropertyName="Text" ConvertEmptyStringToNull="false" />
</SelectParameters>
</asp:SqlDataSource>

</form>
<hr />
</body>
</html
Thanks for the help.

I've been wondering about this as well. I'd really, really like the ability to do this. I came up with a short test page to validate the issue outside of my site.

The code for the test page is below. Run this, click "Add Control" and a label will be added to the placeholder control. Click "Refresh" and watch the label control vanish. You can also validate in the debugger that the label control added to the placeholder has disappeared (that is, it's not in the controls collection at Page_Load time()).

Is there something obvious I'm overlooking?

--

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void Add_OnCommand(object sender, CommandEventArgs e) { Label lab = new Label(); lab.Text = "Dynamically added label"; TestPlaceHolder.Controls.Add(lab); } protected void Refresh_OnCommand(object sender, CommandEventArgs e) { }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Dynamically added control test</title></head><body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" /> <atlas:UpdatePanel ID="TestPanel" runat="server"> <ContentTemplate> <asp:PlaceHolder ID="TestPlaceHolder" runat="server"></asp:PlaceHolder> <asp:Button ID="TestAddButton" runat="server" Text="Add Control" OnCommand="Add_OnCommand" /> <asp:Button ID="Refresh" runat="server" Text="Refresh" OnCommand="Refresh_OnCommand" /> </ContentTemplate> </atlas:UpdatePanel> </form></body></html>

^^^ Nevermind. My example didn't state the case correctly. I went back and fixed it and found everything was fine with values updating on dynamic controls.

The problem was in my site with an off-by-one error in control names. With the names corrected, everything is fine.

Saturday, March 24, 2012

Accentuation problem

I've an UpdatePanel that has textbox and dropdownlist inside it.
In the textbox I put words with accent, for example: á é í, and the dropdownlist has a AutoPostback = True.
When the SelectedIndex event happens, these controls are reloades but the words that a put with accent shows wrong, ex: ?? ?? ?-

How I correct this?

How about letting the dropdownlist have its own updatepanel?

WS


'Cause all the controls are in the same table, will stay complicated to separate the <td> tags to all the dropdownlist that exists.
But I'll try to do this.


I did your suggestion but the problem happens in the grid now.
I put the words in the text box, select all the dropdownlists and click on a button.
This click save the resulto to a DataGrid, when the resuts go to DataGrid, the words are wrong (accent).

accentuated characters loss with updatepanel

Hi,

I would appreciate if you could tell me how to prevent accentuated characters áéíóú losing when updatepanel postback, the updatepanel refresh a listbox that is filled from a textbox, but in listbox appears unicode characters instead.

example:

é -->??

Thanks

Hi!,

Did you try using the HTML character code instead of the actual letter? (Like é instead of é )

http://www.w3.org/MarkUp/html-spec/html-spec_13.html

Cheers,

About Sys.WebForms.PageRequestManagerParserErrorException error

Hello everybody,

My ajax powered web site throws an error when pressing a button or linkbutton inside an UpdatePanel.

I've searched for a solution. All of the blogposts, solutions etc is about the "common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled." suggestion written in the error text itself.

But in my scenario, only IE6 (and may be below) users see this error. I am using IE7, and my site works like a charm. (all my friends using IE7 doesn't have problems with the site)

I've searched my code for response.write stuff but there isn't any. I've removed some custom controls (msn like popup win, flash container controls etc.) but it's the same with IE6 users. The error is :

--------
Microsoft Internet Explorer
--------
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near 'eTitle||Favorilerim|

0

'.
--------
Tamam (OK)
--------

Anybody have suggestions?

Hi bsarica,

Maybe this article is useful for you:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312496

Regards,


I forgot to mention smthng.

It is not working on firefox too.


Any other suggestions? :(


I had a very similar error when I encountered code where the asynchronous call back was making a call to Server.Transfer(). I'm not sure whether or not this helps you or not, but doing a Server.Redirect() fixed the problem for me.

about new atlass document

I found that the new atlas's document(http://atlas.asp.net/docs/Default.aspx) had used atlas's updatepanel.
Where to download the new atlas's document's source code?

You can download the latest Atlas CTP drop from this URL:http://atlas.asp.net/default.aspx?tabid=47&subtabid=471

Hope this helps,

Scott


thanks for your reply.
I had download it .But I can't find new atlas document's source code files.(I had old document's source code.)
How to get it?

I'm not sure what you mean by "old document's source code". Can you explain more? What document are you referring to?

Thanks,

Scott

Wednesday, March 21, 2012

A question on UpdatePanel

Hi All,

What's the different between 1 & 2?

1. <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate> (Content) </ContentTemplate></asp:UpdatePanel>

2. <asp:UpdatePanel ID="UpdatePanel1" runat="server"> (Content) </asp:UpdatePanel>

Thanks,

Stard

1 is the correct syntax. UpdatePanels have only 2 controls which are allowed inside, <ConentTemplate> and <Triggers>. Add the updatepanel as you in example 1 and place your controls within the ContentTemplate

2 wouldn't work or compile as far as i know

A Question about Atlas Update Panel

I have a questio about atlas update panel!

I upload files with ms FileUpload control in the Atlas UpdatePanel, but always failed. I donnot know why. It's weird, when I set the ScriptManager EnablePartialRendering = false, everything is OK! what's wrong with my UpdatePanel?


Thanks for your help?

Many thanks!

Chinese boy!

Unfortunatelly you cannot use fileupload control within updatepanel.

I am pretty sure it was discussed here a time ago, try to find it here, there is more description why it is not possible

Nice day

Milo


oh..My!!

Thanks for your reminding! anyway it's a big flaw of MS atlas. could you tell me where the discuss post was? I want to know more about this bug!

Thank you again!


HI liuguoping

some note in documentation can be found here:http://atlas.asp.net/docs/Server/Microsoft.Web.UI/UpdatePanel/DeclarativeSyntax.aspx

and some threads in forum dealing with it are i.e. here:

http://forums.asp.net/thread/1301989.aspx
http://forums.asp.net/thread/1321664.aspx
http://forums.asp.net/thread/1361452.aspx

You will be able to find more, try to put "uploadfile updatepanel" into top right search textbox on this page.

Nice day,

Milo


Thanks a lot!

A problom about updatepanel

If I put a gridview into the panel, the gridview's paging and sorting become useless.

Why? Is there a good point to instead ?

useless? what exactly are you asking? is something not working?
Hi,
It is not a problem about the update panel. You have to write a code for it.
For example:
<cc1:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridViewID="GridView1" runat="server" Style="z-index: 102; ">
</asp:GridView>
</ContentTemplate>
<Triggers>
<cc1:ControlEventTrigger ControlID="GridView1"EventName="PageIndexChanging" />
</Triggers>
</cc1:UpdatePanel
Bind a datagrid with a suitable data in page behind code.
Add a code in code behind like this.
Protected Sub GridView1_PageIndexChanging(ByValsender As Object, ByVal e AsSystem.Web.UI.WebControls.GridViewPageEventArgs) HandlesGridView1.PageIndexChanging
GridView1.PageIndex = e.NewPageIndex
End Sub
You wil get it work.
Enjoy programming.
Smile
Hi,
Make sure another thing ..
Check that EnablePartialRendering=true property in script manager.
If you didnt add this property to script manager everything works as usual with postback.
Regards,
Enjoy programming,
Muthu Kumaran.D
(Unknown is Ocean)
This is incorrect. If the gridview is inside the update panel, why do you need the trigger? I've set mine up normally (with full postbacks), then added 4 lines, open and close <atlas:UpdatePanel> and <ContentTemplate> and that was all it took.
hi rchern13,
I agree that I am wrong. But I should inform you that this method also working correctly.

A group of PostBackTrigger in my updatepanel

I use a repeater to print out information (hyperlinks) from my database. When you click a hyperlink I want to update a updatepanel.

The problem is that the controlID for each link must be typed in a PostBackTrigger to work perfectly. I can't add PostBackTriggers at run time? Any solutions?

Regards Gustav


Can't you set your updatepanel's mdoe="Always" ?
If I remove my triggers and set UpdateMode="Always" the updatepanel updates without Ajax.

The easiest maybe to handle the hyperlink click event on the server side, and update the desired updatepanel in the click event by the .Update() method.

For handling all hyperlink click event in single event in the server side, and determine which link was clicked: check msdn for handling events in repeater, this is a regular asp.net task not ajax. Search for: "How to: Respond to Button Events in DataList, Repeater, or GridView Items"