Showing posts with label menu. Show all posts
Showing posts with label menu. Show all posts

Wednesday, March 28, 2012

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.

Monday, March 26, 2012

Access SiteMap via Web Service

This is not strictly an Atlas question, but it seems that someone here is most likely to be able to help.

To build an Atlas enabled menu control, I'd like to be able to get access to my sites SiteMap data via a web service. And ideally, I'd like to be able to access data from custom SiteMapProviders in this way.

Is this possible?

Thanks

Ok, so I don't know what I was doing wrong, but I was under the impression that I couldn't get to the SiteMap from the context of a web service. I was wrong.Smile

Saturday, March 24, 2012

Abort aysnc request when user clicks a menu link on the web page

Hi,

I've got my web page working with ASP.NET AJAX but the problem is when I click a link on pages menu I don't get taken to the new page until the page I'm on has received all the async. data from the server.

So, I need to know how to abort the async. requests when the menu link is clicked so it takes me straight to the newly requested page.


Thanks
Jon

You may want to look at the update progress. I think the at least the older releases had a way to do that there.
Hi,

You can use the following javascript function to abort an async call.

function CancelAsyncPostBack()
{
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
}

Hope this helps.

Hi,

Just to test this, I added button to my page which calls the Cancel javascript function. After clicking this button I then click one of the menu links and I don't get taken to the new page until the AJAX stuff has finished.

Below provides more information and hopefully clarifies what I'm doing.


1) On page load a javascript function is called which loops through each row in the DataList table and makes an asynchronous call to a webservice method on the server.

2) It takes 10-20 seconds for the server to calculate the details for each request and then return the results to the callback function on the client, where the results get shown in appropriate columns of the DataList table.


I have 10 rows in my table so end up making 10 near simultaneous calls to the webservice on the server. Whilst waiting for the server to finish responding to these requests I click a link on the page and I want to be taken to the new page immediately. As it stands, I have to wait for the server to respond with all the requested data.


So, my questions are:

1) how do I stop the client waiting for the rest of the data so it goes to the new page?

2) Is it possible to tell the webservice on the server to quit working on the problem?

Thanks
Jon



The reason is because of theInternet Explorer's Simultaneous Connections Limit which is 2 by default.
Please refer to this: ?http://weblogs.asp.net/mschwarz/archive/2005/10/20/428047.aspx

speedbird:

?1) how do I stop the client waiting for the rest of the data so it goes to the new page?

2) Is it possible to tell the webservice on the server to quit working on the problem?

As far as I can tell, there isn't a good way to achieve your requirement.

Hello,

Q) how do I stop the client waiting for the rest of the data so it goes to the new page?
A) What you can do is use JavaScript or HTML anchor to redirect the client to a different page.

Sample: HTML Anchor: <a href=URL_Name target="_self">Click to go to different page</a>

JavaScript Function
function Redirect()
{
location.href='http://www.asp.net';
}

<asp:hyperlink id="hlRedirect" Text="Click Link to Go" onclick="Redirect(); return false;" style="cursor: hand;" runat="server" />

Sample URL:http://forums.advancemicrotech.com/threads/thread051507.aspx
Note: The Start Thread button is the same as your webservice doing its job. Once you click Start Thread button, the thread goes to sleep for 10 seconds, same as your webservice doing something on the server. During this time, you can either click the Redirect button that is created with HTML or the ASP Hyperlink ... as shown above ...


Q) Is it possible to tell the webservice on the server to quit working on the problem?
A) No you cannot tell the webservice to quit working while it's doing its job.

Hope these help ... Cheers.