.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Codeblocks and UpdatePanel

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :ASP.Net


I have a reference to a control (rcbModels) using a codeblock like this

function pageLoad() {

      models = $find("<%= rcbModels.ClientID %>");

I added an UpdatePanel to this page but I always get the following error: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."

I have tried changing the codeblock to:

function pageLoad() {

      models = $find("<%# rcbModels.ClientID %>");

And DataBinding on the Pre_RenderComplete event without success.

What's the best way to solve this issue ?

View Complete Post

More Related Resource Links

UpdatePanel is not a known element - message when upgrading to 1.0 ajax


It worked on one of my old pages.  I change the web.config, renamed all the <asp.

On some aspx page it doesn't recognize the updatepanel.  It only does on one page.  If I create a new aspx page with a different name - then it works.

Should I just create a new web project ajax - then copy all my code into there?  Or is there a way to get those old pages to recognize the new ajax controls?

Gridview inside updatepanel


I am displaying large amount of data in gridview,the gridview placed within updatepanel,every 1sec i am refreshing updatepanel using ajax timer.my problem is while displaying large data the cpu performance is low,pls give idea to increase cpu performance..

Wicked Code: UpdatePanel Tips and Tricks


Jeff Prosise explains when it's better to use UpdatePanel and when it's better to use asynchronous calls to WebMethods or page methods instead.

Jeff Prosise

MSDN Magazine June 2007

How do you insert a google map into an ajax updatepanel?


I have built a site that I am using google maps on.  The default page has a google map with info windows containing links and all works great... until a user clicks on the link in the info window.  Doing so takes them to a community page that I have built.  On this community page, I have an ajax update panel that has 2 panels nested inside of it with the visibility set for one to be on and the other off.  The default panel shows community photos, and the second panel I want to show the google map and common directions to the community.  In testing, my buttons to switch the visibility of the panels works great as it should without postback, but when I try to add the map to its panel, it does not show up.  I am new to ajax as well as google maps and I'm not sure why the same code would work fine on my default page but not the community page.  The only obvious thing I can assume is because the community page map is in an update panel.  

How do you insert a google map into and ajax updatepanel and have it work correctly?  Many thanks in advance. 

ModalPopup/UpdatePanel from codebehind, inconsistent behavior onClick


First post bear with me please:

I have a simple form with a list of linkbuttons, each fires the same onclick event which sets an indicator image.  I have a dummy button with style="display:none" which I have set as the TargetControlID of the modal.

onClick event from the imagebutton, the modal is shown via modal.Show().  The cancel button inside the modalpopup fires an event which turns off the indicator image and hides the modal via modal.Hide(). 

The events fire perfectly, it's very simple!  Although after doing some testing I noticed the modalpopup is not presented after the 6-10th cycle of clicking the open event, then clicking cancel.  The grey background appears but it is behind the main panel and the modal is either presented behind this or is just simply not displaying. 

I spent hours researching various methods, implemented the CancelControlID to see if it was somehow tied to my call of modal.Hide() that fails.

This occurs with an updatepanel only.  The behaviour is much cleaner this way, so I would hope to be able to implement this.  I have basically eliminated everything but these two events!  Please help

UpdateProgress with a dummy updatepanel not working


I have a Submit button and some functionality like updating DB and fetching next page in the button click event. This process takes a long time and I want to display a message saying "Progress...." right after clicking the botton. I want to do the same in 20 other pages. So, best way to do it wd be to put the modalpopup MPE or an Updateprogress in a usercontrol or in master page. I first tried putting both of these on the page itself to test and see and neither worked.

I tried using Update progress control with a dummy updatepanel and giving the Submit button as Asyntrigger to the dummy updatepanel. I have also tried using MPE but it didnt work either. Below is an example of what i did..

<asp:UpdatePanel ID="UpdatePanel1" runat=server><contenttemplate><triggers><asyntrigger ID= "Submit"> /> /> />

<asp:updateprogress ID="Progress1" unat=server AssociatedUpdatePanelID="UpdatePanel1"><Progresstemplate>Progress.... />/>

<asp:button ID= "Submit" runat=server >

I have nothing for updateprogress in code behind. Am i missing or doing somethign wrong here? Any help would be appreciated.

UpdatePanel in a Webpart


I'm exploring the usage of UpdatePanels in WebParts for MOSS 2007. The code I have so far for adding a test update panel is this:

                LinkButton goButton;
                goButton = new LinkButton();
                goButton.ID = "butGo";
                goButton.Text = "Go";
                goButton.Command += new CommandEventHandler(goButton_Command);
                goButton.Click += new EventHandler(goButton_Click);

file upload in Create User Wizard Created User event with UpdatePanel Tag wont work?



In my Create User Wizard1 Created User Wizard Event, I am collecting extra information from text boxes and allowing

the user to uplad a file.



I have put the Submit button within an Update Panel Tag but since I have done this it does not work.

Is there a way round it. In this situation would you use a trigger.?


<br />

  <asp:UpdatePanel ID="UpdatePanel2" runat="server">

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  align="middle"
                                            Text="Submit my Profile" />

Total newbie question: Calling jQuery in an UpdatePanel?



Please forgive this ignorant question - I've used ASP.NET AJAX a good deal but I'm new to jQuery.  Specifically, is it possible to call or create jQuery events on the fly via an UpdatePanel?  For example, calling a jQuery modal or animating a Label (or <div> contained Literal), etc.

If anyone has any advice or could point me to some easy tutorials on mixing ASP.NET AJAX and jQuery, I'd greatly appreciate it. 



Cancelling UpdatePanel progress


I have an UpdatePanel that consists of a button and a GridView. The UpdateProgress as shown consists of an image and a "cancel progress" button. The style on the image helps in graying out the controls on the page but still letting the user view those (due to the opacity settings). What is the best way to implement cancelling the progress of loading data into the GridView by clicking the cancel button.

<asp:ScriptManager ID="sm1" runat="server" />
        <asp:UpdateProgress AssociatedUpdatePanelID="upCheckBoxes" ID="upr1" runat="server">
                <div id="container">
                    <img src="images/loading.gif" id="loadingimg" />
	<asp:UpdatePanel ID="upCheckBoxes" runat="server" UpdateMode="Conditional">
	<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" /> 
		<script type="text/javascript">   
			Sys.Application.add_load(BindEvents);     //Doing some jquery stuff here

Run a javascript function after UpdatePanel.Update()


I thought that adding the javascript within the ContentTemplate would cause it to run every time the UpdatePanel was updated.  For example, I would assume that for the following:

<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Conditional" >
        Hello from inside the update panel!!!!
        <asp:Button ID="foo" runat="server" OnClick="foo_Click" Text="Click me to postback!" />
        <script type="text/javascript">alert('Javascript, baby!');</script>

 would cause the function alert() to run every time the UpdatePanel returns from the button click.  This is not the case, however.

How do I do this?  My update panel contains a scrolling Div and I

Modal Popup with UpdatePanel


Hi Guys,

              I have one Panel on ascx control to which I have attached one Modal popup extender. On this panel I have one RadioButtonList control which having SelectedIndexChanged on which I have made CheckBoxLists visible True/False. 

             I want to add Update panel to this Panel . So when I handled the SelectedIndexChanged event there should be no total page post back, only Panel updates should be happen.

 Please do reply..



UpdatePanel - UpdateProgress only displays on initial postback



I'm having a somewhat odd issue, I'll do my best to explain it.

In a nutshell I have an UpdatePanel with an UpdateProgress item, first postback checks for warnings, if there are any they will be be displayed to the user as a JavaScript 'confirm' box. If the user clicks OK the next postback occurs to commit the change.

The UpdateProgress loading notification appears on the first postback but not on the second, even though both of them function correctly.  The buttons that trigger both postbacks are async postback triggers in the update panel, and both are inside the ContentTemplate.

It's not a huge problem, but it causes some confusion, has anybody ever seen this issue before?


Validation Controls Inside UpdatePanel

Hi All,If you use validation control, the base validator will render script WebForm_OnSubmit() to the page and add form onsubmit "onsubmit="javascript:return WebForm_OnSubmit();". This script is used to fire client side validation event.Now I have a listview inside updatepanel, when click edit button to fire the listview edit mode, the above validation script is just not rendered. How shall I work around with that? I need to customize the client validation event here.Thanks.

registering PostBackTrigger for UpdatePanel...

I need linkbutton outside of updatePanel to be able to refresh/postback only the updatePanel.It works ok, on the first click, on every second click, the whole page is refreshed... :Othx allHere is the "very simple" code:--- aspx ---<form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Label ID="Label2" runat="server" Text="Label">Static Text:</asp:Label> <br /> <asp:LinkButton ID="LinkButton1" runat="server">LinkButton01</asp:LinkButton><br> <hr/> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Label">Text in UpdPanel</asp:Label> </ContentTemplate> </asp:UpdatePanel> </div> </form> --- code behind ---Public Partial Class update Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label2.Text = Now Dim trig As New AsyncPostBackTrigger trig.ControlID = LinkButton1.UniqueID t

Problem with UpdatePanel postback

Hello,I have a Modal Popup window, inside an Update Panel object, that has the following layout:A Title areaA Content area with a tabstrip of 5 tabsA footer area with two buttons (Save and Cancel) and an UpdateProgressIn 3 of the five tabs I have:an UpdatePanel (UpdateMode=Conditional) that wrapsA collection of LinkButtons objectA gridviewAnother Panel object to be showed as a Nested Modal PopupNO update ProgressBoth the link collection and the gridview Select event will open the nested Modal window that contains a custom Usercontrol that is used to add new or edit object of the related gridview like in the code sample below//click handler of the LinkButton protected void btnNewPhone_Click(object sender, EventArgs e) { //Setup properties of the UserControl code omitted // ... //Show the nested Popup this.mpePopupPhone.Show(); } //handler for the gridview selectedIndex event protected void gvPhones_SelectedIndexChanged(object sender, EventArgs e) { //Setup properties of the UserControl code omitted // ... //Show the nested Popup this.mpePopupPhone.Show(); } Please note that: I am using the ModalPopupExtender show/hide behaviors using only server-side code. Also, the ModalPopupExtender objects for nested modal windows does not have the OkControlID & CancelControlID set. As the content of nested modal window is only a single user contro

AutoPostback in Repeater in UpdatePanel is refreshing the page

Here's quite a weird problem:I've got a TextBox with AutoPostBack="true" and OnTextChanged property set.The textbox is located inside a Repeater, which in turn is located inside an UpdatePanel.Problem is - whenever the TextBox postsback, the whole page gets reloaded, instead of the UpdatePanel only.Here's how the thing looks:<asp:UpdatePanel runat="server"> <ContentTemplate> <asp:Repeater ID="itemsRepeater" runat="server"> <HeaderTemplate> <ul class="lstProducts"> </HeaderTemplate> <ItemTemplate> <li> <asp:TextBox AutoPostBack="true" OnTextChanged="whatever_Click" runat="server" /> </li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater> </div> </ContentTemplate> </asp:UpdatePanel> Interesting thing is, if I take the TextBox out of the repeater, it refreshes only the UpdatePanel.So is if I put a Button inside the repeater - only the UpdatePanel gets refreshed.But whenver I place an AutoPostBack-ing control inside the Repeater, the whole page gets refreshed.Any help would be welcomed,Thanks<asp:UpdatePanel runat="server">             &
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend