Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Monday, March 26, 2012

ListBox control with AJAX

HI,

I have three listboxes on a .aspx 2.0 Framework web page. When selection(s) are made in 1st list box the next two list boxes will change accordingly, and when selection(s) are made in 2nd listbox third list box will change, and this can be other way around. My problem is how do i apply Atlas toolkit's extenders to this, or how do i impletement this with ASP.NET AJAX. Any help is really really appreciated.

sirulu

Hi All,

I am also having the same problem.

I am implementing the AJAX Toolkit control in web application.
In my web application i have the folowing scenario:

Select Country from Dropdownlist

Select State from Dropdownlist

Select multiple Cities from Listbox

But i am not able to use List Box control with the AJAX cascading drop down extender.

Please let me know how to use List Box control with the AJAX cascading drop down extender.

Thanks in advance.


Regards,
Sudhir Kumar


Hi All,

I am implementing the AJAX Toolkit control in web application.
In my web application i have the folowing scenario:

Select Country from Dropdownlist

Select State from Dropdownlist

Select multiple Cities from Listbox

But i am not able to use List Box control with the AJAX cascading drop down extender.

Please let me know how to use List Box control with the AJAX cascading drop down extender.

Thanks in advance.


Regards,
Sudhir Kumar

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 ascx in other Page using Ajax

I have one application, which has one Home.aspx, Head.Ascx and Footer.Ascx, Head.aspx has two button, And all controls of head.ascx and footer.ascx in ajax panel, now in home page when i click on one button then i want to load head.ascx in my Home page and if i click on second button then i want to load footer.aspx in Home page and unload Head.ascx. I am using ajax in my application. But not enable to solve this.

Thanks

Hi,

Here is an example made according to your requirement:

<%@. 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 btnHeader_Click(object sender, EventArgs e) { ViewState["show"] = "h"; } protected void btnFooter_Click(object sender, EventArgs e) { ViewState["show"] = "f"; } protected void Page_PreRender(object sender, EventArgs e) { if (ViewState["show"] != null) { string show = ViewState["show"].ToString(); if (show == "h") { Control ctrl = this.LoadControl("Header.ascx"); PlaceHolder1.Controls.Add(ctrl); } else { Control ctrl = this.LoadControl("Footer.ascx"); PlaceHolder1.Controls.Add(ctrl); } } }</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:Button ID="btnHeader" runat="server" Text="Show Header" onclick="btnHeader_Click" /> <asp:Button ID="btnFooter" runat="server" Text="Show Footer" onclick="btnFooter_Click" /> <asp:Button ID="Button3" runat="server" Text="Another Button" /> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>

Thanks Raymond Wen , it solved

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

Load Tab Content when user selects the Tab

Hello,

I am creating a web page with two different tabs. The data for both tabs is from single aspx file under a single Content.

How can i make my second tab load its content when user clicks it?

Regards

HI .

When you click on one Tab . data will be populated from DataBase or its only Static Content .IF it is Static Content then Use Div for Each Tab and Clicking on tab Show one Div and hide another div


Both tabs are Gridviews data (data populated from database).

As of now, my page has both grids loaded with data and it just loaded once from the server.

But like i said, i need the second Tab only populated when user clicks it.


take a look at this link... its help ful

http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html

Wednesday, March 21, 2012

loading an aspx page in ajax updatepanel

Is there a way to load an aspx page in the updatepanel or into a ajax tabcontainer control? Please advise

The only way that I have heard of is using iFrames, but we haven't used that because either page transitions don't matter to us or end up using a different technique to change the content in a particular area of the page (it depends on the page).

loading another page using AJAX

Hi All,

I am new to AJAX. I have two pages:login.aspx andindex.aspx. I am able to redirect user from login.aspx to index.aspx after successful login. But I would like to know is there any way to load index.aspx over login.aspx (so that it should not post back the page). Means, when I redirect user from one page to another page, browsers Back button gets enabled because page is being changed. If page gets loaded over same page using AJAX then there will be no post back. So, browsers Back button will remain disabled. Is there any way to do this?

Thanks

Sumit

Hi Sumit,

Well there is no way that you can redirect to other pages without a page flickering. Ajax supports partial page updates which means that parts of page can be refreshed but the user stays on the same page. There is a control available which is called "history" this control should make the back button available.

Hope this helps.

Regards,

Loading external .aspx file into AJAX Toolkit TabPanel

Hello,

I'm new to ASP.NET AJAX. I want to create a default page, maybe a master page. then i want to add the AJAX Toolkit TabContainer with different TabPanels for each of my other .aspx files (home.aspx, about.aspx, etc.) I want to know how I would setup the TabContainer with a tabpanel for each page and load those pages when the appropriate Tab is clicked. a small snippet of example code would be greatly appreciated

Thanks to all in advance

GL

How about something like this?

<ajaxToolkit:TabContainer ID="tabs" runat="server" Width="600px" Height="400px">
<ajaxToolkit:TabPanel ID="tabHome" runat="server" HeaderText="Home">
<ContentTemplate>
<iframe src="http://pics.10026.com/?src=home.aspx" width="100%" height="100%">
</iframe>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="tabAbout" runat="server" HeaderText="About">
<ContentTemplate>
<iframe src="http://pics.10026.com/?src=about.aspx" width="100%" height="100%">
</iframe>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>


Thanksctafield, that did the trick. works like a charm but I wonder if there might be another way besides frames. I dont like to use frames plus i'm concerned about browsers that may not support frames. Thank you for the quick response

If there is another way I would greatly appreciate the guide

Thanks

GL


Ok, When I used the iframe my pages end up having 2 separate vertical scrollbars. one for the main window and one for the iframe region. i cna see that confusing my users when they need to scroll up or down. has anyone thought of another solution?

you can actually turn off the scrollbars for the iframe - just make sure you set its width and height to 100% so data doesn't get chopped and that would get rid of the scrollbar for the iframe...

<

iframeid="TargetPane"scrolling="no"


Hi,

You might also be interested in reading one of Scott Guthrie'sblog posts where he created a class called ViewManager to render ASP.NET controls to HTML and send it via a webservice to the page.

Thanks,
Ted


You can add WebControls (.ascx) to each panel you want by using following code-behind:

AjaxControlToolkit.TabPanel tpHome = new AjaxControlToolkit.TabPanel();
tpHome.HeaderText = "Home";
tpHome.ContentTemplate = Page.LoadTemplate("Home.ascx");
tcDefault.Tabs.Add(tpHome);

AjaxControlToolkit.TabPanel tpAbout = new AjaxControlToolkit.TabPanel();
tpAbout.HeaderText = "About";
tpAbout.ContentTemplate = Page.LoadTemplate("About.ascx");
tcDefault.Tabs.Add(tpAbout);

tcDefault is TabContainer control.


AjaxControlToolkit.TabPanel tab = new AjaxControlToolkit.TabPanel();
tab.HeaderText = "test_new_tab";
TabContainer1.Tabs.Add(tab);

??index error WHY?

Good piece of code to use the control on the code behind.
Even the control toolkit samples didn't have these in detail

However i couldn't load an external page onto the page.loadtemplate method
It throws the following error when trying with full path


Exception Details:System.Web.HttpException: 'http://localhost:8080/Documents/9245/bjk49000.PDF' is not a valid virtual path.

Any suggestions?

Rain Man


At the moment i'm using the following method by coding on the client end

<ajaxToolkit:TabPanel runat="server" ID="TabPanelAttachment" HeaderText="Attachments">
<ContentTemplate>
<iframe runat="server" id="iframePreview" width="850" height="800" frameborder ="0"> </iframe>
</ContentTemplate>
</ajaxToolkit:TabPanel
var urlPrefix = "http://localhost:8080/Documents/"
var urlSuffix = docId + "/" + fileName;
var url = urlPrefix + urlSuffix;

$find('TabContainerDocument').set_activeTabIndex(1);
document.getElementById('TabContainerDocument_TabPanelAttachment_iframePreview').src = url;

TabContainerDocument_TabPanelAttachment_iframePreview is the iframe id at run time
Hope that helps for someone who is trying on something similar

Happy coding

Rain Man


This reallyhas to be built into the TabPanel tool.


Haven't tried this but it might be another alternative to controls and iFrames...

Dynamic drive website has example of using Javascript to do page calls to a div, not too sure if will work in but might be good for a try?

http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

Dave

Loading UserControl Dynamically in UpdatePanel

i'm using this technique (http://geekswithblogs.net/rashid/archive/2007/08/11/Loading-UserControl-Dynamically-in-UpdatePanel.aspx). it works well.

however, i'm trying to add javascript to UserControl2 and the javascript never executes. it appears that the javascript never renders to the page.

help.

What approach are you using to add the JavaScript?

-Damien


i've tried embedding the javascript directly onto the page. i've also tried adding the javascript via using RegisterStartupScript in my Page_Load event.


Ensure you are using ScriptManager RegisterXXX method instead of Page.

loading web user controls asynchronously

I am new to asp.net ajax. I want to load multiple web user controls in a aspx page independently after the page has been loaded so that user will know that something is happening in the page rather than showing them blank screen. IS there a way to do it using Ajax or is it not possible to do so?

any help would be appreciated

You could have update panel for each user control that have a timer set as their trigger. When the timer elapses, load the user control you want into each update panel. use an update animation in each to let the user know something is happening.


This seems a bit backwards. UserControls become a part of the page itself, so delaying their "loading" isn't likely to help you. If you want to show some sort of progress or other indicator to the user while the page is processing, you can do that with an animated gif or with Remote Scripting ("AJAX").


how can i achieve remote scripting using asp.net ajax. The problem is i have couple user controls that runs heavily in database and it takes about 5 seconds to finish. I want to display the remaining content in the page while the user control is loading.

please help.


hello.

well, the only option i see is to laod the page without that content and then call a web service from the client side that gets the data from the server and presents them to the user. you should keep in mind that an asp.net page generates html that is sent back to the client. this means that you cannot sent the page to the client with "wholes" that will be filled up later...it simply doesn't work like that!


It's true you can't leave holes in the HTML, but that doesn't mean you need load everything at one time.

If you modify your user control to not load the data that takes five minutes on page load, but only to load it when a certain method is run you can load the user controls in the update panels as I suggest above and then you can trigger the data to be loaded into it via a timer, or a java script function that runs when the page loads in the client's browser.


hello again.

true, but in those cases, why not simply call a web service and then use js to update the ui without incurring in another partial postback?


If you do that can you use the updatePanel animation to notify the user that something is happening or do you have do it manually with js?


hello.

well, the updateprogress is really a wrapper around client behavior that is responsible for showing/hiding the contents you define. the upadteprogress is "tied up" with the partial postback model based on the server side approach.

nothing prevents you from doing something like this is js:

1. define the wait msg in an html element that has its display style set to no none

2. start the web service call and change the display of the element defined on 1

~3. handle the cb and error cb methods and make sure that you set the style of the element defined on 1 to none

yes, you do have to write some js code, but when you think about it, the J in AJAX stands for Javascript, right? :)


i am thinking to call the update panel after onload event using javascript. is there any idea how to call update panel using javascript.


hello.

well, the easiest way i've seen is to call __doPostBack and pass it the client id of the panel you want to update:

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


I just came accross a post where xr280xr says he acomplished exactly what you're trying to do using a timer.http://forums.asp.net/t/1176152.aspx


well, i'm sure that the timer has its uses, but if you just want to refresh the panel after the page has been loaded through js code, the link i've mentioned is the best option.


I'm happy to defer to your increased experience and knowledge on this, but can you explain why it would be preferable to go through the hassle of manually writing a JS function to do it as opposed to just using the timer as described in that post. I truly don't mean this in a rude way; I just don't see the benefit. Could you explain?


Luis,the link you provided is not working. would you please provide again.