Sending asynchronous request on clicking a sharepoint web part button control - asp.net

I am new to this whole sharepoint and aspx programming. I have developed a sharepoint web part that has a button control. The onclick event is mapped to a method in my web part code. When I click the button the whole page reloads and the web part is rendered again. Is there a way to prevent this reloading of the page? Is there a way to call the function method in the background? Something similar to AJAX.
Thanks,
Jagannath

You can use Ajax, it just requires some sharepoint configuration. Here are a few posts to get you started:
http://weblogs.asp.net/jan/archive/2007/02/26/using-the-ajax-control-toolkit-in-sharepoint.aspx
http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3

Ajax or SilverLight are your only two options for Async operations without a page refresh.

Once you know the tricks needed to get SharePoint and ASP.NET AJAX to work together it's not that difficult.
Here are the steps required:
Ensure the ASP.NET AJAX Extensions are installed on all the front-end web servers (this is not required if you are using .NET 3.5 as the Extensions are included in the Framework)
Update the Web.config file for the SharePoint Application to support ASP.NET AJAX
Ensure any page that is going to use AJAX has a ScriptManager
Use an UpdatePanel or a client-side service call to get updated data and re-render the Web Part
This blog post has some resources from a talk I did on the subject at TechEd Barcelona 2008. These resources should give you the information you need to get started.
http://msmvps.com/blogs/windsor/archive/2008/11/13/teched-emea-resources-and-demos-integrating-asp-net-ajax-with-sharepoint-2007.aspx

Related

How CMS handles postback for integrated web applications?

Currently I am working on a project to integrate legacy application (ASP.NET) with a content management system. There are two web servers, one act as cms server which is public facing and other the legacy application website behind the firewall. CMS drive the show to render header, footer, left and right info pans and menu.
My requirement is to show the legacy application aspx pages inside a content area of cms. Everything works fine except postback. The form submits to cms website whereas I want it to postback to legacy application.
How CMS or SharePoint achieve this? For example if a webpart is having a submit button which postbacks,
how SharePoint submit the form to webpart? What is the architecture behind this?
I'm not sure what you are asking. You're talking about a legacy application hosted in some kind of Iframe and it not being able to post back? Well of course?!
In SharePoint when you build a WebPart you can just use any server side method and it automatically posts back - just regular ASP.NET there, nothing special.
Sometimes a PostBack is called via Javascript for which the _doPostBack() Javascript method is used.

Open Sharepoint Application Page inside ASP.Net web app

I have the unusual situation to solve... There is a application page that runs inside SharePoint 2010 with a form to upload some file to a Document Library.
The thing is that this application page needs to be showed on a modal inside my ASPX web app.
I got this running using simplemodal jquery plugin running inside a iframe.
My question is... how can I achieve this functionality considering security questions like a controlled access to this application page? My SharePoint site does not allow anonymous access so I need to figure out how to allow public access only on this page.
I would re-create the page in this asp.net application and then communicate with sharepoint using the client object model or perhaps another approach such a custom webservice (but client model should be ok). I would say that this is the only clean way to achieve your goal.

How to browser display asp.net controls on its page when it is said it strictly understands only html content and scripts?

I m learning asp.net basics. i was going through tutorial at www.dotnetspider.com
and there it is explained browser understands only html content and scripts strictly. So when i create a webform and drop asp controls and run how does my browser understad that control content and displays on its page?
Your browser doesn't understand the ASP.NET controls. ASP.NET understands them. Whenever a web form is request ASP.NET takes the form and converts it into the HTML form and any scripts that are needed and sends them down to the browser.
Using the ASP.NET web controls makes your job easier, you don't have to worry about hooking together a bunch of HTML forms and code. But as the website says, it's all HTML to the user's browser.
Update:
When I say "ASP.NET understand them" I'm really talking about the ASP.NET frameworks and IIS (Microsoft's web server). So the request the User's browser sends out arrives at IIS. It knows from the URL that this is a request for an ASP.NET application. So it uses the ASP.NET code to take the .aspx pages and the .ascx controls and convert them into the HTML response. It then sends that HTML to the User's browser. So ASP.NET (and IIS) sit "in the middle" between the web broswer on the User's computer and the ASP.NET code and pages you write.
i just did found detail so i thought to write it might make it more clear in depth. its goes as
Browser sends request to IIS -> goes to ISAPI dll(written in C++) -> Loads CLR Process where each control have render method finally emitts its html code -> Which browser can understand and display. Please correct me if i m wrong some where.

How to raise an Event in asp.net application from a silverlight application

I have a Silverlight application hosted inside an asp.net website. In my silverlight applicaiton, if I select a theme. Then, theme changes will gets fired. I want to get notified in asp.net web page, when the theme changed event is fired inside the silverlight application.
Note: Also, I don't want to use a data base to maintain the state of the application.
You can't easily raise an asp.net application event from your Silverlight App. It should be possible, but would require your SL app to do a POST request on the server with POST parameters interfacing well with the ASP.NET plumbing. It's hacking, I would say that's not the recommended way to do it and if you do it asynchronously (without reloading the page), it could do weird things with your viewstate.
You can however call a web service from the SL app when the user change the theme. (the webservice could be something as simple as a request handler or an aspx page with get parameters or maybe a WCF service)
You could then store values about the selected theme in the user session.

ASP.NET Ajax feature in existing ASP.NET website

I have a ASP.NET Website which was developed in ASP.NET 2.0.
Now I want to add a new page to the project which will make use of the ASP.NET AJAX features like Partial page updating.
Is there any options to do this ? Do i need to change any settings for this in my already existing project /Solution ?
The only problems you may run across is inside you web.config file if you don't go in and register the asp.net ajax assemblies.
Other than that you should be able to add a scriptmanager control and work with the page like any other asp.net ajax page.
Edit: Here is some documentation that should help you configure ASP.NET AJAX to an existing website.
http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx
There is a great tutorial about how to implement AJAX on a regular ASP.NET web site.
http://www.asp.net/learn/ajax-videos/video-81.aspx
Hth...

Resources