Showing posts with label click. Show all posts
Showing posts with label click. Show all posts

Wednesday, March 28, 2012

UpdateProgress not showing up

I have a page which has a FormView control and when I click one of the rows I get an ModalPopup for editing the detailed information. This works, however it takes too long for ModalPopup to open. Since I haven't found any solution for speeding up the ModalPopup, I thought I might as well inform the user that the data is loading on the background. I also thought that I might give UpdateProgress-control a try. I know that this is not the best solution for this (performance) issue but so far is the best I can figure out.

My page looks like this:

<Button> (hidden)
<ModalPopupExtender>
<Panel>
<UpdatePanel>
<FormView>
</UpdatePanel>
<UpdateProgress>
</Panel>

So what I would like is that before ModalPopup is visible, user gets an message presented by UpdateProgress, that something is going on. However with this current setup, nothing happens, UpdateProgress is not activated. Any ideas why ?

The ModalPopupExtender and the popup control have to be inside the UpdatePanel for UpdateProgress to be activated.



Hi,

Here an example of how to procede with.

<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional">

<ContentTemplate>

<!-- Place here your ModalPopupExtender and the popup control -->

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdateProgressID="UpdateProgress1"DynamicLayout="false"runat="server"DisplayAfter="50">

<ProgressTemplate>

<spanstyle="font-family: Trebuchet MS; color: #ffffff;">Chargement...</span</ProgressTemplate>

</asp:UpdateProgress>

<ajaxToolkit:AlwaysVisibleControlExtenderID="AlwaysVisibleControlExtender1"runat="server"TargetControlID="UpdateProgress1"HorizontalSide="Center"VerticalSide="Middle"HorizontalOffset="0" />

Kind regards,


Ok,

Thanks both, I try to take look at this bit more today.


I tried this and it works, thanks !

One question though, why is AlwaysVisibleControlExtender needed, because the examples I have seen are done without this ? I always thought that UpdateProgress would be the only control needed here.


Happy to see that it works.

k000der:

I tried this and it works, thanks !

One question though, why is AlwaysVisibleControlExtender needed, because the examples I have seen are done without this ?

This extender is just here for managing the UpdateProgressExtender position. As you can seeHorizontalSide="Center"VerticalSide="Middle"

are for specifying the position in the screen where you would like to have the loading displayed, and even if you are scrolling up and down inside the page, you'll see that the position will always stay where you define it.

Kind regards,


Ok, now I see why it's needed. Thanks again.

Updating a Cell (TD) in a Table

Hi all,

I am developing a webcontrol and I am also developing an AjaxExtender for these control...

Now the problem is when I register an click Event, I works fine, but I would like to replace the

value of one special cell with the result I get from Sys.Net.WebServiceProxy.invoke(),

since I am not so familiar with javaScript and all these Ajax stuff ;) I would like

to ask you guys if you have any advice for me to do that...

thanks in advance,

Omid

It depends a bit on your table structure and how you have things marked up with id's and so on. The easiest possible case is that your TD has a unique id, in which case you can easily say:

$get('idoftheelement').innerHTML = resultsOfTheInvoke;

if you don't have a unique id for it, it's somewhat more complex, but generally it's easiest if you use array notation, for example,

var table = $get('idOfthetable');

var rows = table.getElementsByTagName('TR");

var firstRow = rows[0];

var firstRowTds = firstRow.getElementsByTagName("TD");

var lastTd = firstRowTds[firstRowTds.length-1];

once you have the TD you want, you can set its innerHTML property to the texto f the result param.


hi Paul,

thank you very much for the advice...

My Table and rows and Cols have all an unique ID,

so I think $get('idoftheelement').innerHTML = resultsOfTheInvoke; fits to me...

redards Omid.

ps. I have another little question... what will happen if the ID is not Unique?? will I get an Array?


ID's have to be unique. I've honestly never tried to do them otherwise, since the spec requires them to be. I imagine you'd get different results in different browsers and depending on your doctype declaration.

one thing to watch out for when using the Id is that if your table is a server control and its inside a Master page or a User Control, then ASP.Net will munge the server-side ID to keep it unique (in case you have mulitple instances of the same control o nthe page, etc). The solution to that is to either not use the id (use some other means such as the one described) or else embed the server-generated id somewhere on the page inside a <script> block such as : var myTableId = '<%= tblMain.ClientID %>';

Monday, March 26, 2012

Updating an UpdatePanel through a LinkButton command generated by a repeater

Hi everybody,

I would like to refresh an update panel when I click on a Linkbutton generated by a repeater that looks like this:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<li>
<asp:LinkButton ID="LinkButton1" runat="server" OnCommand="FilterByPrize" CommandName="filter" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "NameID")%>'>
<%# DataBinder.Eval(Container.DataItem, "Name")%> </asp:LinkButton>
</li>
</ItemTemplate>
</asp:Repeater>
The command called is the following:   
 protected void FilterByPrize(object sender, CommandEventArgs E){string connString ="connstring"; SqlConnection IVR =new SqlConnection(connString);string finalquery ="sqlquery " + E.CommandArgument.ToString() +" order by TimeStamp desc"; SqlDataSource2.SelectCommand = finalquery; SqlDataSource2.DataBind(); userData.DataBind();} 
The problem with this is that it reloads the whole page instead of only the update panel. Is there a way to refresh the updatepanel from a function in the c# code called from a linkbutton?
Thanks

MrClash,

The update panel has an Update() method that will do this. But I'm afraid that you are going to have register the linkbutton with the update panel. Take a look at this thread.

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

Good luck! And feel free to provide some more details if this doesn't work.
Regards.

Updating DetailsView Control with AJAX

I have a ListBox, and when I click on an item in the ListBox I want to populate my DetailsView control with that item. How do I do this with AJAX?

Pretty simply actually.

You will want to put AutoPostBack="true" on your ListBox declaration.

Youll then want to wrap your DetailsView inside an UpdatePanel, set the Updatemode to conditional. Also add 1 trigger to it with the ControlID pointing to your listbox, and the eventName as SelectedIndexChanged(the event your listbox will fire when selected is change).

in your code behind you're going to have an eevent fired with the listbox has it's index changed. In that event you will do the work to populate your detailsview based on what was selected.


I'm getting an error that says 'Sys' is undefined when I run this in IE now. Here's the code that it's erroring on...

<script type="text/javascript">
<!--
Sys.Application.initialize();
// -->
</script


Can you show more of your script/markup?

Do you have extra client side functionality in your page?


Sure, here's the entire source code of the page...

<!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><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="EmpOrderInfo.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjAyNTkzODI1MQ9kFgICAw9kFgQCAw8QDxYEHg1EYXRhVGV4dEZpZWxkBQdHcm91cElkHgtfIURhdGFCb3VuZGdkEBUFBDczNzcENzM3OAQ3MzgxBDczODIENzM4ORUFBDczNzcENzM3OAQ3MzgxBDczODIENzM4ORQrAwVnZ2dnZxYAZAIFD2QWAmYPZBYCAgEPPCsADwEADxYEHwFnHgtfIUl0ZW1Db3VudAIBZBYCZg9kFiRmDw8WAh4HVmlzaWJsZWhkZAIBD2QWAgIBDw8WAh4EVGV4dAUENzM3N2RkAgIPZBYCAgEPDxYCHwQFCTIyMzA2MjY1NGRkAgMPZBYCAgEPDxYCHwQFBVdISVRFZGQCBA9kFgICAQ8PFgIfBAUHR1JFR09SWWRkAgUPZBYCAgEPDxYCHwQFATFkZAIGD2QWAgIBDw8WAh8EBQExZGQCBw9kFgICAQ8PFgIfBAUVMS8xMS8yMDA3IDEyOjAwOjAwIEFNZGQCCA9kFgICAQ8PFgIfBAUGJm5ic3A7ZGQCCQ9kFgICAQ8PFgIfBAUKMDAwMTY3OTMwNmRkAgoPZBYCAgEPDxYCHwQFCjAwMDE2NzkzMDZkZAILD2QWAgIBDw8WAh8EBQUxNS4wMGRkAgwPZBYCAgEPDxYCHwQFBTU1LjAwZGQCDQ9kFgICAQ8PFgIfBAUEMC4wMGRkAg4PZBYCAgEPDxYCHwQFBDAuMDBkZAIPD2QWAgIBDw8WAh8EBQEwZGQCEA9kFgICAQ8PFgIfBAUUMS8xLzAwMDEgMTI6MDA6MDAgQU1kZAIRDw8WAh8DaGRkGAEFEG9yZGVyRGV0YWlsc1ZpZXcPZ2SqwxUXyPNrKdRopgFCgoT+NqtULg==" />
</div
<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script
<script src="http://pics.10026.com/?src=/WebResource.axd?d=FpwRBZ96xZ5ud99miA75mw2&t=633202882958381326" type="text/javascript"></script
<script src="http://pics.10026.com/?src=/ScriptResource.axd?d=LdKoE2V7baQxgZi5qJWDJL19jIzUAhV9R9vHBQErnKHQwiApaevwRqa0lkzD8pUgnd1f2nCFAiPcZKH9m548d5BH2dJtnoaxfupo3UPI0DE1&t=633270221986802216" type="text/javascript"></script>
<script src="http://pics.10026.com/?src=/ScriptResource.axd?d=LdKoE2V7baQxgZi5qJWDJL19jIzUAhV9R9vHBQErnKHQwiApaevwRqa0lkzD8pUgnd1f2nCFAiPcZKH9m548d-Ek16dyKFudPIusY3WzCMCytLJROrx7r4IKoGi2fnci0&t=633270221986802216" type="text/javascript"></script>
<div>
<div>
<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1'], ['orderListBox'], [], 90);
//]]>
</script
<table border="1" style="; height: 500px">
<tr>
<td style="width: 200px; height: 500px" valign="top">
<select size="4" name="orderListBox" onchange="javascript:setTimeout('__doPostBack(\'orderListBox\',\'\')', 0)" id="orderListBox" style="height:100%;width:100%;">
<option value="7377">7377</option>
<option value="7378">7378</option>
<option value="7381">7381</option>
<option value="7382">7382</option>
<option value="7389">7389</option
</select></td>
<td align="left" style="width: 400px; height: 500px" valign="top">
<div id="UpdatePanel1">

<div>
<table cellspacing="0" cellpadding="4" align="Left" border="0" id="orderDetailsView" style="color:#333333;height:100%;width:100%;border-collapse:collapse;">
<tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">GroupId</td><td>7377</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">SSN</td><td>223062654</td>
</tr><tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">LastName</td><td>WHITE</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">FirstName</td><td>GREGORY</td>
</tr><tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">OrderTypeId</td><td>1</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">IssueTypeId</td><td>1</td>
</tr><tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">IssueDate</td><td>1/11/2007 12:00:00 AM</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">CaseName</td><td> </td>
</tr><tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">CaseId</td><td>0001679306</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">CaseNum</td><td>0001679306</td>
</tr><tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">WeeklyDedAmt</td><td>15.00</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">WeeklyDedPct</td><td>55.00</td>
</tr><tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">MaxMonDedAmt</td><td>0.00</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">OriginalBalance</td><td>0.00</td>
</tr><tr align="left" valign="middle" style="color:#333333;background-color:#F7F6F3;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">LifeOfOrder</td><td>0</td>
</tr><tr align="left" valign="middle" style="color:#284775;background-color:White;font-size:X-Small;white-space:nowrap;">
<td align="left" valign="middle" style="background-color:#E9ECF1;font-size:Small;font-weight:bold;width:150px;white-space:nowrap;">DedExpDate</td><td>1/1/0001 12:00:00 AM</td>
</tr>
</table>
</div>

</div>
</td>
</tr>
</table>
</div>

</div>

<div
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBwL5ica2AQLIgsfhCgKojMF/AqiM9ZQGAoPm+eMMAoPm7cYHAoPmmboBzmXMwzecNn5uwbSob2JtclG3CR8=" />
</div
<script type="text/javascript">
<!--
Sys.Application.initialize();
// -->
</script>
</form>
</body>
</html


The "Sys is undefined" error asside, does your page do what you need it to do? ASP.NET creates that section of JavaScript, so for some reason the rest of the scripts are not being loaded.

Try looking at this post - http://forums.asp.net/p/1040236/1446560.aspx they had the same issues that you have.


Looks like it's related to anonymous user access. I'm checking into it now. Thanks!


Nevermind, this was it...

<httpHandlers>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>

Now I have a problem with the 'SelectedIndexChanged' event. It's executing code that sets the DataSource of the DetailsView Control and then calls the DataBind() method again and it's not doing anything on the page. Any idea why?


I did some more research and it looks like the ListItem.Selected value isn't being set when I click on that item in the list. Why is this? The DataSource for my ListBox is an array of user-defined objects and the DataTextField is set to the name of one of the properties in the object. This is my code in the 'SelectedIndexChanged' event on the ListBox...

int index = 0;

foreach (ListItem i in orderListBox.Items) {
if (orderListBox.Items[index].Selected) {
loadDetails(index);
}
index++;
}

None of the items in the ListBox are 'Selected'.


It's working now. Not sure what I did though :)


I'm glad you got it working :)


Ok, now it stopped working and I have no idea why. The 'SelectedIndexChanged' event is firing, but none of the items in the ListBox are 'Selected' in the Item array. Help?


Do you have code that is interacting with the listbox at all? Any javascript?

Changing anything on the listbox (Clicking on an option in it or having an option chance) will invoke taht even.t


Not that I know of. Here's my code...

protected void orderListBox_SelectedIndexChanged(object sender, EventArgs e) {
int index = 0;

foreach (ListItem i in orderListBox.Items) {
if (orderListBox.Items[index].Selected && orderListBox.SelectedIndex != selectedIndex) {
loadDetails(index);
}
index++;
}
}

private void loadDetails(int listIndex) {
OrderInfo tmpOrderInfo = new OrderInfo();

try {
pdfButton.Attributes.Remove("OnClick");
pdfButton.Attributes.Add("OnClick", "javascript:window.open('OrderView.aspx?id=" + orderInfo[listIndex].OrderId.ToString() + "')");

orderDetailsView.DataSource = tmpOrderInfo.GetOrderInfo(orderInfo[listIndex]);
orderDetailsView.DataBind();
} catch (Exception ex) {
string tmp = ex.Message;
}
}

Updating one Ajax Panel from another

I have two pannels one is a grid and the other is the details pannel. Once you click on the grid the details panel is updated (the grid is a trigger to the detials). What i need is once the user update the details panel, the original grid needs to be update with the new information. If i set a button on the details panel as the trigger for the grid panel, it does not work (recursive triggers?).

How do i do it?

chaim turkel

Hi,

if your panels UpdateMode is conditional, you can always rely on Update method to force updatePanel refresh from your server code.

-yuriy


You have to set UpdateMode="Conditional" & have to be use UpdatePanel.Update() method.

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

Updating UpdatePanel from User Control

Im havin problem s trying to update an UpdatePanel outside a User Control. This UP is suposed to update when i click a control in the UC.

I tried to add a trigger programmaticaly from when the UC loads.
Also tried the RegisterAsyncPostbackControl from the UC (this.Page.Master.FindControl("ScriptManager1").RegisterAsyncPo...)

none of this is working and i dont know hot to access the UC from the master page.
The user control is not contained in the master, is contained in an aspx using a master page.

The UpdatePanel is contained within the master page

Thanks

Show us some HTML and code behind would be helpful.


Hi,

You can use ScriptManager.GetCurrent(this) method in the content page to get reference to the ScriptManager instance. Try this:

ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(ucInstance);

Please note that UP doesn't support add trigger programatically.

Hope this helps.


Raymond Wen - MSFT:

Please note that UP doesn't support add trigger programatically.

Are you sure? The updatepanel trigger collection has an add method. I can add a trigger programatically to the updatepanel with that method, just tested.

AsyncPostBackTrigger t = new AsyncPostBackTrigger( );
t.ControlID = yourTriggerItem.ClientID;

yourUpdatePanel.Triggers.Add( t );


stmarti:

Raymond Wen - MSFT:

Please note that UP doesn't support add trigger programatically.

Are you sure? The updatepanel trigger collection has an add method. I can add a trigger programatically to the updatepanel with that method, just tested.

AsyncPostBackTrigger t = new AsyncPostBackTrigger( );
t.ControlID = yourTriggerItem.ClientID;

yourUpdatePanel.Triggers.Add( t );

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

Programmatically adding AsyncPostBackTrigger controls is not supported. Use the RegisterAsyncPostBackControl(Control) method of the ScriptManager control to programmatically register a postback control, and then call the Update() method of the UpdatePanel when the control posts back.

I haven't got the exact reason yet, but it's not recommended to do so. It may work, but can't guarantee anything.


Maybe it's supported/works, just not for any control on the page. /"The control that theAsyncPostBackTriggerreferences must be in the same naming container as the update panel forwhich it is a trigger. Triggers that are based on controls in othernaming containers are not supported...", and other restrictions applies./

I think it's safer to tell in the doc, that useRegisterAsyncPostBackControl(Control) and the update method, because it works for any postback control on the page.

Thanks for the clarification.


Thanks for your reply. This seem helpful.

I was wondering why im not getting the initialization script when the page is rendered to the browser:

Sys.WebForms.PageRequestManager._initialize('ctl00$Manager', document.getElementById('aspnetForm')); --- I took this from another application where partial rendering works just fine.

Im not getting this lines at the begining of the document.
Meybe this is the main issue. How can I get this lines to generated. I have compared both apps and the web.config has the same structure.

Thanks for your help


Raymond,

After using your code example those lines that were missing appeared in the rendered paged.

But still the page is doing a normal postback.


Here is a sample made according to your situation, please try it:

[Master]

<%@. Master 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"
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>

<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

[Page]

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %><%@. Register src="http://pics.10026.com/?src=WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <uc1:WebUserControl ID="WebUserControl1" runat="server" /></asp:Content>

[UserControl]

<%@. Control Language="C#" ClassName="WebUserControl" %><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { UpdatePanel up = this.Page.Master.FindControl("UpdatePanel1") as UpdatePanel; up.Update(); } protected void Page_Load(object sender, EventArgs e) { ScriptManager sm = ScriptManager.GetCurrent(this.Page); sm.RegisterAsyncPostBackControl(Button1); UpdatePanel up = this.Page.Master.FindControl("UpdatePanel1") as UpdatePanel; up.UpdateMode = UpdatePanelUpdateMode.Conditional; }</script><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />

Wednesday, March 21, 2012

Use a menu control in updatepanel

that occurs a javascript error when click another tab: "0.cells" is null or not an object.

who can help me? thanks.

The menu control is not compatible with partial-page updates and can't be used inside a UpdatePanel.


what can i do if i want to implement this function?thx.
Could you run this in JS debugger and post a snippet of affected JS.. I vaguely remember dealing with this issue and it might allow us to see what is exactly happening

did quick google

and found e.g. this

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


thanks for your information, i read a blog and using this method it works well.

http://mcosier.blogspot.com/2006/12/0cells-is-null-or-not-object-aspnet-20.html

but i have a problem that:

it seems that using AsyncPostBackTrigger can't change the StaticSelectedStyle after i clicked another menuitem?

thanks.


I've been using this piece of javascript to go around the menu problem:

var oldMenu_HideItems = Menu_HideItems;if(oldMenu_HideItems){Menu_HideItems = function(items){if (!items || ((typeof(items.tagName) =="undefined") && (items instanceof Event))) { items = __rootMenuItem; }if(items && items.rows && items.rows.length == 0){ items.insertRow(0); }return oldMenu_HideItems(items);} }
I got it from the asp:menu javascript code and I hook it to "patch" the problem.
Adding it to a page where a menu resides makes the javascript error go away. 

This one works great for me.

Thank you very very much.Big Smile

Great


it is working.. Smile Thank you for your great solutions.

thanks t0yBig Smile

i tryed it.and i dident give that error.

thanks again.


Dear sir

can you please tell me where to put this code in what event, name of the function it is very imp.

thank you,

please advise what to do.


This piece of Javascript has saved me hours of googling! Awesome work buddy and thanks heaps!

See for more info , which controls are not compatable with UpdatePanel

http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx


I cannot figure out how to use this fix. I put this script in my page and I'm still getting the 0.cells is nothing error.

How do I hook this up?

Thanks!


Have you tried the solution thatt0y provided..

It's working..Smile