Showing posts with label div. Show all posts
Showing posts with label div. Show all posts

Monday, March 26, 2012

listbox in updatepannel takes to long

Hello, I have an updatePanel and inside of it i have textbox, listbox and div. And it all works perfecly if in the listbox i have to 100 rows. But in few cases i have arround 6000 rows. The problem occures when i select a row from the lisbox with 6000 rows and I'm tryning to put some message into the Div. It assignes the InnerHtml of the div and waits for about 1 minute with 100% processor activity and then it displays the div content. How can i shorten this time? Any sugestions?

Thanks

The UpdatePanel passes the ViewState for the whole page each time you do this, not to mention it sounds like 6000 records are being rebound. Remember the whole UpdatePanel needs to update... A better approach would to be use something like PageMethods to get the message (seehttp://encosia.com/index.php/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous) and then fill the DIV client-side.

-Damien


See the following thread and side threads for a long discussion of the problem and code that will cut the update time to milliseconds if your listbox is simple.

http://forums.asp.net/p/1065352/1540804.aspx

There are other ways of doing it as Damien suggested, but most of them involve the PageRequestManager (http://www.asp.net/AJAX/Documentation/Live/ClientReference/Sys.WebForms/PageRequestManagerClass/default.aspx) as the best solution.


http://forums.asp.net/t/1065004.aspx


Actualy I solved it with this link:

http://encosia.com/index.php/2007/07/13/easily-refresh-an-updatepanel-using-javascript/

Saturday, March 24, 2012

Load a web page, play with the html code and paste in a DIV

Hi,

I have a default.aspx page and I want one of it's frames to present a web page from another site. I tried using JS AJAX and found that is is impossible to do this across sites. It there a way to get the server to get a web page, allow me to play with it's html code and then paste it in a div in default.aspx?

I know how to get my I default.aspx page to invoke a function on WebServer.asmx, but have no idea how to get a web page in VB. Can someone explain how / redirect me to an explaination?

Thanks
Yoni

Check this article:http://msdn2.microsoft.com/en-us/library/system.net.webrequest.aspx


If it's in a frame anyway, it seems like you might be adding needless complexity by trying to do this on the client side. For good security reasons, there will always be limitations on what you can do cross-domain on the client side.

You could just set that frame's src to a RemoteContent.aspx (or whatever) page on your site, and have that make the web request on the server side, manipulate it how you want, and then present it.


gt1329a:

If it's in a frame anyway, it seems like you might be adding needless complexity by trying to do this on the client side. For good security reasons, there will always be limitations on what you can do cross-domain on the client side.

You could just set that frame's src to a RemoteContent.aspx (or whatever) page on your site, and have that make the web request on the server side, manipulate it how you want, and then present it.

and how can I do this? also, can I put it in an iframe?
Thanks,
Yoni


MSDN has good information on how to use the WebRequest class (as someone else linked above): http://msdn2.microsoft.com/en-us/library/system.net.webrequest(VS.80).aspx

It would work fine in an iframe. Just set the iframe's src to your RemoteRequest.aspx (or whatever) and have that do the processing on the server side and output what you want to appear in the iframe.


gt1329a:

MSDN has good information on how to use the WebRequest class (as someone else linked above): http://msdn2.microsoft.com/en-us/library/system.net.webrequest(VS.80).aspx

I tried to get the following page but keep getting a timout error:
http://he.wikipedia.org/w/index.php?title=%D7%AA%D7%91%D7%A0%D7%99%D7%AA:%D7%94%D7%A2%D7%A8%D7%9A_%D7%94%D7%9E%D7%95%D7%9E%D7%9C%D7%A5&action=render
Why won't Microsoft's WebRequest example work with this page?
Yoni


I'm not sure why that would time out. Is there anything blocking outbound connections to port 80 on the server you're testing this on?

Another thing you might want to look at issetting the request's user agent to a popular browser's. Wikipedia might have some sort of restrictions in place to deter scrapers from stealing its content.


Thanks. I managed to load the page using the following code:

Dim wcAs WebClient =New WebClient()wc.Credentials = CredentialCache.DefaultCredentialswc.Encoding = System.Text.Encoding.UTF8wc.Headers.Add("Content-Type","application/x-www-form-urlencoded")wc.Headers.Add("User-agent","User")Dim resAs Uri =New Uri("http://he.wikipedia.org/w/index.php?title=%D7%AA%D7%91%D7%A0%D7%99%D7%AA:%D7%94%D7%A2%D7%A8%D7%9A_%D7%94%D7%9E%D7%95%D7%9E%D7%9C%D7%A5&action=render&ctype=text/plain&dontcountme=s")Return wc.DownloadString(res)
Thanks for your help.

Load an aspx nto another aspx with ajax

HI

I have a aspx page with a table and 1 DIV tag. I have a another aspx page with table and 2 maskedit ajax control toolkit.

I want to load second page into DIV of first page when user load first page. I want to show progress bar and after load completed second page added into first page (DIVpart)

can anyone help me for writting this code?

best reagrds

Not sure about the divs but you can accomplish this with .Net and Masterpages and multiple contentplaceholders...


Thank you for replying my post.

But can you write a small example for me that I can insert a aspx page into another one with AJAX. I need second page has a maskedit control toolkit and I can insrt it into first aspx page.

Best regardsEmbarrassed


Really sorry I can not - as I stay away frm master pages where possible -- however you can take a look the AjaxControl ToolKIt sample website (which you can download) and play around with it for yourself...

load page in div using ajax --> ajax functionality lost :s

Hi all,

I found some javascript on the net to load a page in a div. Now the problem is that the loading of the page in the div works, but then when I use ajax-functionality in the page loaded in the div, the page just refreshes.

Here I found the code:http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

Here is a simular thread (his issue got resolved but mine not. On his site things seem to work just fine :s):http://forums.asp.net/t/1163067.aspx

Here is my working demo showing what goes wrong:

This is my situation:

    I have 2 pages: Default and Content.Default loads Content on it's page (using the "loading a page in a div"-logic)Content has basic ajax functionality which works from Content itself.Content's ajax func. won't work when it's loaded on Default.
The Default.aspx page (no codebehind to keep it simple):
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false"%><!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>Default</title><script type="text/javascript">var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)var loadedobjects=""var rootdomain="http://"+window.location.hostnamevar loadstatustext="<img src='img/loading.gif' /> Requesting content..."function ajaxpage(url, containerid){var page_request = falseif (window.XMLHttpRequest) // if Mozilla, Safari etcpage_request = new XMLHttpRequest()else if (window.ActiveXObject){ // if IEtry {page_request = new ActiveXObject("Msxml2.XMLHTTP")} catch (e){try{page_request = new ActiveXObject("Microsoft.XMLHTTP")}catch (e){}}}elsereturn falsepage_request.onreadystatechange=function(){loadpage(page_request, containerid)}page_request.open('GET', url, true)page_request.send(null)}function loadpage(page_request, containerid){if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))document.getElementById(containerid).innerHTML=page_request.responseText}function loadobjs(){if (!document.getElementById)returnfor (i=0; i<arguments.length; i++){var file=arguments[i]var fileref=""if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceedingif (file.indexOf(".js")!=-1){ //If object is a js filefileref=document.createElement('script')fileref.setAttribute("type","text/javascript");fileref.setAttribute("src", file);}else if (file.indexOf(".css")!=-1){ //If object is a css filefileref=document.createElement("link")fileref.setAttribute("rel", "stylesheet");fileref.setAttribute("type", "text/css");fileref.setAttribute("href", file);}}if (fileref!=""){document.getElementsByTagName("head").item(0).appendChild(fileref)loadedobjects+=file+" " //Remember this object as being already added to page}}}
</script></head><body> <form id="form1" runat="server"> </form> <p> <a href="javascript:ajaxpage('Content.aspx', 'contentarea');">test</a> </p><div id="contentarea"></div></body></html>

The Content.aspx page (also no codebehind to keep it simple):

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" %><script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadMe.Label1.Text = DateTime.Now.ToString End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)Me.Label1.Text = DateTime.Now.ToString End Sub</script><%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %><!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>Content</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div><asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate><asp:Label ID="Label1" runat="server" Text="" Width="138px"></asp:Label><br /><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate></asp:UpdatePanel> </div> </form></body></html>

Could anyone please give it a try? I don't know what's going on.
The code above should work! Just make the 2 pages and copy the entire code into it.Thanks!

Kind regards,
Wim

My guess would be that your Content.aspx page contains some sort of window.onload event-handler to wire-up the Ajax stuff, but when you load in Content.aspx into Default.aspx using Ajax its window.onload event will not fire (the window.onload event will already have fired when Default.aspx was loaded).


ijoxley:

My guess would be that your Content.aspx page contains some sort of window.onload event-handler to wire-up the Ajax stuff, but when you load in Content.aspx into Default.aspx using Ajax its window.onload event will not fire (the window.onload event will already have fired when Default.aspx was loaded).

Hi ijoxley,

Thanks for your reply ...

But when I look at my code that's posted above, I don't see anything unusual happening in any onload event.


deblendewim:

But when I look at my code that's posted above, I don't see anything unusual happening in any onload event.

That's true - but its probably hidden away somewhere in the JavaScript generated by the ScriptManager tag.

It might be an idea to add a ScriptManager to the Default.aspx page then writing some JavaScript to handle the DOMNodeInserted event (for when you load Content.aspx into your <div> tag).


Anyone?


hello.i'm not sure on what you're trying to do here, but the approach you're using isnot the best to use if you're using asp.net ajax. ok, regarding your problem, i agree with the previous answeres you've received: the client portion of the asp.net ajax platform needs to run several pieces of code during the load event of the page. when you load a page like that, you're not getting that event and this means that your updatepanel won't be ready for patial postbacks.in my opinion, you should use only one page and if you need to change the contents of the page, then you can use one or more usercontrols to achieve that (instead of having several pages that are loaded into the center of your main page).

Load Page in DIV

Hello,

if someone can help me, I'm newbie on ASP.NET and I'll try to find information about best practice to include aspx page of my site in DIV (AJAX) when a user click on link in the navigation menu

like this : http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm#combo

I didn't find any good article or tutorial about this in ASP.NET AJAX :-(

Can I find specific control in control toolkit or future ctp ?

Thansk a lot for your help

read this article if you want to load a page with in the div element.

http://www.xul.fr/ajax/responseHTML-attribute.html

For latest ctp and downloads.

http://www.asp.net/ajax/downloads/


Thanks for this link !

Is it a better solution to use updatepanel control (trigger by menu link) and ascx user control inside this updatepanel ? if yes, someone know where I can find good tutorial for this ?


See this link

http://asp.net/ajax/documentation/live/tutorials/UsingUpdatePanelUserControls.aspx