Wednesday, March 21, 2012

how can i load anout url without refreshing page with ajax?

how can i load anout url without refreshing page with ajax?

I mean can i load another webpage without refreshing current window?

HI Dear,

You can window.open() (Javascript method) to open new Popup window, without refresing current page.

window.open("Anotherpage.aspx","WindowName","scrollbars=1,resizable=1,location=0,url=0s,status=1,width=700,height=350");

First Parameter is the Target Page URL that will be shown in the Popu WIndow

Second Parameter is Window Name '( Can be Anything),

Third Parameter is page attributes like scrollbar, Page height, width etc

Thanks

Best Regards,

Muhammad Akhtar Shiekh


i know how to open a pop-up but my problem is not opening a pop-up window, i want to load another page without refreshing to current window.

Hi,

Hope I didn't misunderstand you. Here is a sample you may try:

<%@. Page 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 Button1_Click(object sender, EventArgs e) { System.Net.WebRequest req = System.Net.WebRequest.Create("http://localhost/MyAJAXSampleSite/HTMLPage.htm"); System.Net.WebResponse rep = req.GetResponse(); System.IO.StreamReader sr = new System.IO.StreamReader(rep.GetResponseStream()); string temp = sr.ReadToEnd(); Literal1.Text = temp; }</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> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>  <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:Literal ID="Literal1" runat="server"></asp:Literal> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

The html page to be loaded:

<!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> <input id="Button1" type="button" value="button" /> <input id="Reset1" type="reset" value="reset" /> <input id="Submit1" type="submit" value="submit" /> <input id="Text1" type="text" /></body></html>

No comments:

Post a Comment