Contents tagged with ASP.net AJAX

  • Setting jQuery after ASP.net AJAX partial post back

    Tags: .NET 4.0, ASP.net, ASP.net AJAX, jQuery

    OK, so for some reason you have a mega mashup solution with ASP.net AJAX, jQuery and web forms. 

    Perhaps you are just on the migration from AjaxControlToolkit to the jQuery UI framework – who knows!!

    Anyway, the problem is that when you post back with something like an UpdatePanel, you will find that your nicely setup jQuery stuff, like the datepicker for example will no longer work.

    You may have something like this…

    1. $(document).ready(function () {
    2.     $(".date-edit").datepicker({ dateFormat: "dd/mm/yy", firstDay: 1, showOtherMonths: true, selectOtherMonths: true });
    3. });

    When you’re ASP.net UpdatePanel post back, you will find that your datepicker has gone.  Bugger!

    Well you need to add this little gem to set it back up again once the UpdatePanel comes back to the page.

    1. var prm = Sys.WebForms.PageRequestManager.getInstance();
    2. prm.add_endRequest(function () {
    3.     $(".date-edit").datepicker({ dateFormat: "dd/mm/yy", firstDay: 1, showOtherMonths: true, selectOtherMonths: true });
    4. });

    Or like me, you would have a javascript function, something like InitPage(); do all your work in there and call that on document.ready and endRequest.

    Your choice…you have the power Smile

    Share this post :

    more...

  • Go Sharepoint : From the beginning

    Tags: SharePoint, ASP.net AJAX, .NET 3.5

    Right, the virtual server is up and running...time to soak up some SharePoint...get some dnrTv episodes down my throat.

    Sahil Malik recorded a series of SharePoint episodes, 4 in fact. He starts with what happens when SharePoint is installed and finishes with some massive XML files for a Business Data Catalogue application. Tip: They are an hour long, so watch it in fast mode, the talking speed is still good and it only takes 30 mins to watch.

    Session 1

    Session 2

    Session 3

    Session 4

    Note: You can get the XML from his website for the BDC apps. You will need Northwind if you want to use them "as is".

    Edit Master Pages

    Using SharePoint designer you can edit the master page of your site - although I didn't do any editing, I did open the master page in designer, just to have a look at it!

    http://msdn2.microsoft.com/en-us/library/ms476046.aspx

    Webparts

    SharePoint is obviously made up of webparts; being able to write your own and add them to SharePoint, I think, is a huge advantage. There are a couple of steps to get them into SharePoint that without some help, you'll never figure out!

    http://www.codeguru.com/csharp/.net/net_asp/webforms/article.php/c12293/

    asp.net AJAX in SharePoint

    http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3 (if you are using the AJAX framework in .net 3.5 you will need to amend the XML accordingly)

    Although I have been able to get the XML done, added a scriptmanager to the master page, I am having problems getting the update panel to wrap the contents. I haven't spent a great deal of time looking at it – perhaps someone is aware of a Gotcha??

    Host WCF service in SharePoint

    http://blogs.msdn.com/gzunino/archive/2007/09/17/hosting-a-wcf-service-in-windows-sharepoint-services-v3-0.aspx

    Use WCF service from outside Sharepoint

    Calling a WCF service from within a custom web part is really, really easy. Basically follow exactly the same steps you would in any other project, just remember to put add the ServiceModel section to the web.config on your SharePoint site. I didn't try this originally as my web part and WCF service are .NET 3.5 and Sharepoint site is .NET 2.0, I thought it wouldn't work, however as .NET 3.5 is an extension to .NET 2.0 it does! :) Happy days! I did consider writing the endpoint code in C#, but when you use a reference to a hosted service, the endpoint is read only.

    Hosting Silverlight

    Join up at http://silverlight.live.com - if you haven't seen it, you can upload your Silverlight apps and movies to MS servers – it's a pretty cool service and if Silverlight is your bag, you NEED to use it!!

    Once you have uploaded your app you, you can either reference the JavaScript files in the page or use an iframe to host the app in your page. Either way, they give you the code to paste in! Which is always nice! To show the control in SharePoint all I did was create my own webpart, override the render contents event and write the code out on the HtmlTextWriter. Same as any other control :)

    Sites

    I created a couple, a blog site and some others, it's pretty self explanatory really, especially if you watch the dnrTv videos.

    Next...

    1. I want to figure out how to call WCF services from BDC applications - direct to SQL is not for me!
    2. More AJAX in Sharepoint, perhaps the toolkit.
    3. Sharepoint API, what can I do?
    4. I didn't touch on Security at all; everything is using the "admin" user. Yuk!
    5. Site content types, Sahil covered these in the second webcast, but I am still not 100% sure how I could make use of these, or if I would even want too!
    6. The other 4 million things that Sharepoint has! It's really big you know! J - Take some guidance on direction from "The Book" when it arrives!!

    Technorati Tags: Sharepoint, MOSS 2007, asp.net ajax, WCF

    more...

  • MIX UK 07 - Day One! Silverlight, hosting, Live Services and ants!

    Tags: .NET 3.5, ASP.net AJAX, Personal, Silverlight, User Group

    Day one is over at MIX UK.  As my first experience of a Microsoft conference I must say I was not disappointed :) The conference opened with a keynote from George Moore and Scott Guthrie and lots of small demos from third party companies and the little apps they have developed using MS technologies, mainly Silverlight, which is the main theme of the conference, well day one at least!!

    In the first and second session I stayed with ScottGu and watched as he ripped through the power of silverlight, present and future.  As well as the basic XAML shapes and textblock, he covered some features of the *special* silverlight CLR.  He also stated that there will be a set of controls (50 was the quoted number!), from basic input controls like the Textbox to more advanced controls like the DataGrid - this for me as a business application developer is fantastic, I have enjoyed playing with Silverlight but didn't really have a "real life" use for it without the ability to databind to controls.  These will be distributed in a similar format to the AJAX Control Toolkit, with full source downloadable which is pretty cool.

    I have a silly little jotter pad I have written as my first silverlight application - I must post it up at some point.  I know, I am gonna get the FREE 4gb of silverlight hosting MS offer and then I'll post the link! You should check out the silverlight hosting - if you plan of hosting video in silverlight to stream then this will save you a fortune in bandwidth etc.  There are limits like only a 10min video can be uploaded (this is due to and MPEG licensing thing apparently - video is not my thing!) You can only upload 30MB at a time.  There is also a limit on the number of minutes streaming you can have but its very high!

    Next, I opted to go for the "Developing Next Gen Web Apps with Windows Live Services", this I regret, not because it wasn't good, Angus Logan and Danny Thorpe did a good job (Angus was pretty humorous) but I just knew most of what they demo'ed (Virtual Earth stuff), I guess I took the safe option as a pose to going to "A nice cup of tea and a sit down" which may or may not have involved interaction from myself - heaven forbid!

    Also didn't help being sat next to someone with an entire colony of blood sucking ants having a carnival in his pants, the chairs are linked together, it got a little hairy at times!!

    We'll see what tomorrow brings!  We have been advised to hang around till the end when swag bags will be distributed...but the contents are yet to be revealed!

    more...

  • ASP.NET AJAX RC1 RSS Reader

    Tags: ASP.net AJAX

    So the other day I was adding a “news page” to one of my projects and thought it was a great chance to play with consuming some other RSS feeds that had related information to what I was working on. So I started looking round and found the RSS Toolkit that had an RSS Data Source control that is perfect for consuming RSS feeds – the toolkit actually does much more, you should have a read on Dmitry’s blog (he wrote the toolkit and in on the ASP.net team) download the toolkit here.

    I have also used the ASP.net AJAX Toolkit (which if you are unaware is a collection of controls for use with ASP.net AJAX, its an open source project with contributors from both MS and the community) the control I use is the Collapsible Panel control so you can see a list of the Blogs and click each to reveal the text.

    To use this you will need to have ASP.NET AJAX RC1 installed.

    Simple page layout using CSS, the right panel contains a Datalist control bound to the RssDataSource to display the blog items, the datalist control is wrapped in an asp:UpdatePanel. The item template in the datalist has a collapsiblepanelextender from the AjaxControlToolkit to display the description of the blog item.

    Chaging the selection of Blog to view fies the asp:UpdateProgress panel to display, the blog items are loaded and displayed.  You can see on the Blog list I have simply shaded the background of the <li> element to show the active blog.

    The code for this is pretty simple with all thanks going to the AjaxControlToolkit team and Dmitry for the RSS reader.

    ASPX Markup

    List of blogs on the left....

    DataList Control.....

    C# Code Behind

    As you can see each Link button is hooked up to an OnCommand Event Handler and the argument identifies which blog feed to bind to the data source.

    ....finally on the page I have added a little bit of Javascript to change the CSS class of the blog list item to indicate which one is active.

    If ele (the <li> element) is null I assume this is the first call and so the element will be list1.

    Hope you find this as useful as I did - download the full source here.

    more...

  • ASP.net AJAX RC1

    Tags: ASP.net AJAX

    So they have released ASP.net AJAX RC1 which is apparently the penultimate release before the fully supported product.

    Couple of new features...

    1. Built in VS 2005 Web Application Project template to create new AJAX application.
    2. Additional globalisation support for AJAX applications, improved substitution logic, compression and caching.
    3. The assembly Microsoft.Wev.Extensions.dll has changed to System.Web.Extension.dll and the namespace Microsoft.Web has changed to System.Web

    Two reasons for the change which will be the last...

    1. ASP.NET AJAX will be fully-supported part of the core .NET framework in the future so for consistency
    2. It will help make upgrading to the Orcas release of ASP.NET and VS much easier.

    You can download or view the whitepaper on upgrading from beta2 here.

    Tip from ScottGu on intellisense. "One additional step you'll want to make after you follow the steps in the whitepaper above is to delete the cached schema files for control markup Intellisense that VS maintains.  This will ensure that your HTML source editor Intellisense for the ASP.NET AJAX controls is correct and doesn't get lost (otherwise it might incorrectly use the old values from the Beta2 release).   

    - With Windows XP you do this by deleting all files in this directory: c:\Document and Settings\[YourUserName]\Local Settings\AppData\Microsoft\VisualStudio\8.0\ReflectedSchemas

    - With Windows Vista you do this by deleting all files in this directory: c:\Users\[YourUserName]\AppData\Roaming\Microsoft\VisualStudio\8.0\ReflectedSchemas

    Once you delete these schema files and restart VS, it will re-calculate the HTML markup Intellisense for all controls and pick up the changes from the assembly name change."Read more from Scott here

    more...