
If you are working with Visual Studio 2008, you might be looking for the Web Control Library template that used to be quite apparent in Visual Studio .NET 2003 and kind of hidden under "File - New - Project - Windows - Web Control Library" in Visual Studio 2005. Check my earlier post on this http://geekswithblogs.net/ranganh/archive/2006/09/06/90370.aspx
Well, in Visual Studio 2008, this option is under "File - New - Project - Web - ASP.NET Server Control". Yeah that is the place you you would find the template to create a Web Control Library.
Thought this was again tricky to figure out and would help if I post the details over here.
Cheers !!!
One of the common queries I get across my sessions is that, the File Upload control doesnt work inside an Update panel. All of us would like to implement a Gmail File Upload kind of interface and when you try to implement a similar thing using UpdatePanel (which works like a charm for other activities), it simply doesn't work.
The behaviour is expected. The File Upload Control doesnt work inside an Update Panel due to security reasons and restrictions a browser implies. They dont allow Javascript files to directly access the files in an user's sytem and dont allow to modify or access the details of a file when working with the File Upload Control.
There are a couple of ways to solve this issue, one using Update Panel and Post Back Triggers and the other using Iframes.
1. Use Update Panel, File Upload Control and use a PostBackTrigger Control to force a postback only for the File Upload Control
This approach works well without much tweaking except for that, there would be a postback only for the File Upload Control. While the rest of the stuff happens asynchronously, using the UpdatePanel, when the user presses the "Upload" Button, the page will be refreshed. Let us examine how we can accomplish this. Place the following code within the <form> </form> tags in your ASP.NET Page.
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Height="20px" onclick="Button1_Click" Text="Submit" Width="128px" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:Button ID="Button2" runat="server" Height="25px" onclick="Button2_Click" Text="Upload" Width="128px" />
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button2" />
</Triggers>
</asp:UpdatePanel>
In the Code behind, add the following lines of code:-
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
}
protected void Button2_Click(object sender, EventArgs e)
{
FileUpload1.PostedFile.SaveAs(@"C:\test\"+System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName));
Label2.Text = FileUpload1.PostedFile.FileName;
}
If you run the above sample, you would notice that upon entering something in the TextBox and clicking "Submit" (Button1) the Label above the File Upload Content, shows the Text you typed, without a page refresh.
However, when you select a file and click on the "Upload" (Button2) Button, you would notice that a postback happens and the file gets posted to the "C:\Test\" folder and also the full path is specified in the Label 2.
In the above code, I have not taken any steps regarding validation, checking if file exists etc., since it just shows how you could accomplish File Upload within Update panel. In normal cases, you would write better code to accomplish a file upload feature.
2. Use Iframes and accomplish a truly Gmail Like File Upload Interface.
I thought of writing a post on this, but did a quick research and found that there are a few solutions posted by our MVPs / Community Folks and just thought of providing a link to the same.
http://vinayakshrestha.wordpress.com/2007/03/13/uploading-files-using-aspnet-ajax-extensions/
http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx
Note that this post doesnt claim any warranty / support for the above articles, though.
Cheers !!!
If you have worked with Visual Studio 2008 and tried creating Mobile Web Applications, you would have figured out that the "Mobile Web Form" template is missing. In the past, in Visual Studio .NET 2003 you had Mobile Web Forms that allow you to create webforms that can be rendered over different types of HTML, WML and XHTML capable devices.
Well, it is not shipped by default in Visual Studio 2008, but Omar Khan from the Web Development Tools Team has put up a few templates that can be downloaded and brings in those Mobile Templates required for creating mobile web applications.
You can download the templates from the Web Development Tools Team Blog Post here There is a "readme" file attached to each of the extracted Zip folders. But to make it simpler, once you install and unzip the package, you get a folder "ASP.NET Mobile Templates" and inside that you might find a bunch of folders.
Copy the Zip folders inside each of the "ASP.NET Web Application" Folders into your system's Visual Studio Templates folder. For instance, there is a folder for "ASP.NET Web Application CS". You need to copy the contents of this file into
c:\Documents and Settings\<username>\My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#
Similarly you would copy the contents of the "VB" folder into the Visual Basic folder under "ItemTemplates" above.
Once you copy these and restart Visual Studio 2008, you would be able to get the "Mobile Web Form", "Mobile Web User Control" and "Mobile Web Configuration File" under "My Templates" in "Add New Item" Wizard.
Cheers !!!
We are delivering Virtual Tech Days on April 9th and 10th (http://www.virtualtechdays.com) delivering a series of webcasts on different tracks ranging from SQL - BI to Visual Studio for Devices. Infact the three important tracks are SQL Server 2008, Visual Studio 2008 and Windows Server 2008.
These would be in depth sessions covering specific topics on each of the above products. For Visual Studio we have dedicated tracks for Application Development and Lifecycle management using Visual Studio 2008 and VSTS. We also have a Web Development track focussing on ASP.NET, AJAX, Silverlight and the recently released ASP.NET MVC Framework Beta. There would also be a track for Visual Studio for Smart client Apps including Mobile Devices.
You could find the detailed agenda at http://www.virtualtechdays.com/agenda.aspx The good thing that we have heard from you folks about webcasts is that, it doesnt require you to travel anywhere and take out time from your hectic work schedule. You could attend all of these from the comfort of your desktop and learn about the exciting technologies and their application in your projects.
The sessions are going to be delivered along with Quiz, Contests etc., and there are exciting gifts promized and believe me, I feel its one good time to be attendee than a speaker for this event.
The whole event would be hosted by Mandira Bedi.
So, for more information and registration visit http://www.virtualtechdays.com/registration.aspx
Looking forward to see you all in the Virtual Tech Days.
Well, if you are a regular reader of my blog, you would have noticed that I have recently uploaded a few videos on Visual Studio and ASP.NET AJAX, powered by Silverlight. A lot of you might want to upload your videos into your web pages, web logs, site etc., and would be wondering on where to upload the videos, how to host it etc., Also, some of you might be waiting to use Silverlight in your website. Well, this post (inspired with my own experience) helps understand on how you can achieve both (use Silverlight as well as host videos on your webpages) together.
The first thing that you would require to upload a video, is obviously the Video. You may want to start recording a screen capture of a simple "How-to" technical article or even on a yummy recipe that you tried. You could record the video using any screen capture tool or can try the free Windows Media Encoder Series
Once you are done with recording a decent size video (say of size 3-4 MB), you are all set to start publishing the video.
Encoding your Video for Windows Live Streaming using Expression Encoder
1. Download Expression Encoder for free
2. Open Expression Encoder, select "File - "Import" and chose the location where you have your recorded video
3. It shows the Imported Video under the Media Content section
4. Select Settings in the right and under Profile adjust the Video and Audio to reduce the size. Typically anything more than 25MB is going to have issues when using Silverlight Streaming. So adjust the settings accordingly.
5. Switch to the Output tab and under Job Output - Template - chose a template for the video. I chose the Silverlight Template which looks cool.
6. Once you are done with the above, click Encode to encode the video file for streaming
7. The Encoded file is typically stored in Documents folder under Expression\Encoder folders.
8. A folder is created for every encoded video
9. When you navigate to this folder, you might find the following files
i. BasePlayer.js
ii. Default.html
iii. Your WMV Video file
iv. MicrosoftAjax.js
v. player.js
vi. player.xaml
vii. PlayerStrings.js
viii. project.csproj
ix. Silverlight.js
x. StartPlayer.js
10. We need to add a Manifest file to the above files.
11. Create a simple .txt file and rename it to manifest.xml. Open it using any text editor and copy paste the following contents
<SilverlightApp>
<version>1.0</version>
<loadFunction>StartWithParent</loadFunction>
<jsOrder>
<js>MicrosoftAjax.js</js>
<js>BasePlayer.js</js>
<js>PlayerStrings.js</js>
<js>player.js</js>
<js>StartPlayer.js</js>
</jsOrder>
</SilverlightApp>
Save this file
12. Secondly, you may not want the video to start playing automatically since it might be a little annoying for your visitors, particularly if there are more than a single video. To avoid this, you can edit the StartPlayer.js file and navigate to the section where it says autoPlay. It is set to true by default. Change it to false. This would make the video play after users click on the same.
13. Once you are done with the above changes, select all the files mentioned above (contents of the folder for this particular video) and Zip them. You would need to ignore the following files while zipping
i. Default.html
ii. Silverlight.js
iii. project.csproj file
14. The zipped file is what you would require to host your video
Silverlight Streaming
Silverlight Streaming is a free streaming resource provided by Windows Live Services It allows you to host upto 4GB Videos for free streaming and is an innovative approach since we take care of the streaming and hosting part. All one requires is a silverlight player installed on the client side to render your video.
You can get a Silverlight Streaming account for free from http://silverlight.live.com Once you create an account, visit the
Manage Applications section and select "Upload a Silverlight Application" link
You would require to provide a name which has no space (little annoying) without hyphen (even more annoying if you are used to using hyphens) and there after Browse to upload the zipped files.
Once you are able to upload the zip file successfully, you would get an URL with an iframe tag and the required properties.
Adding it to your website
Well, all you have to do is to copy the iframe URL provided in the Silverlight Streaming site and paste it into your blog template (switching to HTML View) / website.
Thats it, you could see that your videos are playing powered by Silverlight Streaming.
Happy Silverlight Streaming !!!
Click Here for a text version of this article !
Click Here for a text version of this article
Click Here for a text version of this article
Click Here for a text version of this article
Heroes Happen Here !!! Yeah that is the theme we chose for this launch. After all, arent you guys the Heroes, going out and solving the customer problems that keep creeping in day-to-day?
I had in my earlier post talked about the Visual Studio 2008, SQL Server 2008 and Windows Server 2008 and the sessions I am delivering over the same. Also, we have a community launch that happens across 14 cities. The agenda for the same should be out shortly at the Heroes Happen Here website, keep checking for the same.
Meanwhile, we also have an 80 City launch that would be delivered by our partners (you see, we can't be everywhere
) We are in the process of putting up the content, tracks and the venues for all the cities. Rest assured, its not fun, planning this event, but delivering this is going to be fun because, we are going to reach out to all the small cities and towns where we always encounter brilliant minds. Much as we presume that the IT Folks are from tier-1 cities, there are many cases, when we encounter experts from small towns.
The agenda for the 80 city launch, should also be up shortly in the website.
Post these events, we are going to have a virtual launch during which there will be day long webcast sessions on each product, one each for Visual Studio 2008, SQL Server 2008 and Windows Server 2008, that would happen. You can check for the agenda and registration at http://www.microsoft.com/india/webcasts The pre-launch webcasts are happening right now and if you missed my webcasts on Visual Studio 2008, Web Development and RIA development, you can download the recordings from http://www.microsoft.com/india/webcasts/ondemand.aspx
So, rest assured that you wouldnt miss the action and can always catch up with one of the above events. If you are attending any of these events, we would be glad to meet you and hear from you, your experiences.
Cheers !!!
Yes, we would launch three in a row! Visual Studio 2008, Windows Server 2008 and SQL Server 2008 Launch would be happening on March 4th, 5th and 7th at Bangalore, Mumbai and Delhi respectively.
This launch marks one of the biggest launches we have ever done and we are working hard at it. There are a flood of events planned starting with our pre-launch webcast series happening starting next monday. You can register for the same at http://www.microsoft.com/india/webcasts/ (check the Visual Studio 2008 Webcast Series), and I am speaking on two of the web related stuff.
The next important dates to note are
March 4 Bangalore Launch
March 5 Mumbai Launch
March 7 Delhi Launch
I am speaking at all the above cities on Visual Studio 2008
Then there is the community launch happening in 14 cities across the countries. If you are a part of the UG in any of these cities, you must have received information regarding this.
You can register for all the events at http://www.heroeshappenhere.co.in/Register.aspx
For more information check http://www.heroeshappenhere.co.in/
Cheers !!!
When working with Visual Studio 2005 on Windows Vista and create web applications running out of IIS 7, you need to perform a few steps before getting it work. I had blogged about it, in my earlier post
However, after performing all the above, you might still get "An authentication error occurred while communicating with the web server. Please see Help for assistance" when trying to create a website / debugging a website created using Visual Studio 2005 running on a Windows Vista with IIS 7.
There is a public hot fix available which can be downloaded for FREE.
The Web Dev Tools team put up a nice post on this http://blogs.msdn.com/webdevtools/archive/2007/06/20/downloadable-hotifx-f5-debugging-using-iis-fails-on-vista-home-editions.aspx
Also check http://mvolo.com/blogs/serverside/archive/2006/12/28/Fix-problems-with-Visual-Studio-F5-debugging-of-ASP.NET-applications-on-IIS7-Vista.aspx which provides better explanation with visual steps.
Cheers !!!
If you are working with Windows Vista and IIS7 and developing web applications using Visual Studio 2005, you might want to know certain things before you panic on getting issues with creating http://localhost applications running out of the IIS Webserver.
With Windows Vista, we ensured that security is the utmost important aspect and anything that needs an administrative privielege (could be running a script, could be creating a website in your webroot or simply could be changing your desktop resolution) needs to be confirmed by the end users, triggered by the UAC prompt. If you had been working with Windows Vista, you would have noticed the UAC Prompt appear quite a few times for a number of things. This though looks to be a nuisance, is a wonderful mechanism to prevent fradulent usage of administrative access by hackers. Supposing you visit a site which internally downloads a script and tries to attach your OS System Files, unless the end user confirms, the UAC isnt going to allow to proceed with the operation. Similarly, even downloaded desktop applications which try to mess with the operating system, are well covered by the UAC prompt.
Coming to our case in point, for creating Web Applications running out of IIS7, you need to do a few things. The first thing is to run your Visual Studio 2005 under admin priveleges. You can do that by Start - Run - Visual Studio 2005 and right click on the Visual Studio 2005 icon and select "Run as Administrator". By doing this you get the privelege to create web applications running out of IIS 7. Alternatively you could also create web applications running out of your file folders without requiring the IIS 7. This doesnt require you to chose "Run as Administrator". In these cases, Visual Studio 2005 would use the built-in ASP.NET Server (http://localhost:PortNumber)
Similarly, at the IIS 7 end you need to do a few things. The first step is to enable IIS7, by default, IIS 7 is not enabled in Windows Vista. So visit Control panel - Add Remove Programs (a quick runtime command is "appwiz.cpl" from Run command). Select "Turn Windows Features On or Off" and you would be prompted with a list of Windows Compnents (It takes a moment to load the bunch)
Once you are there, you would just want to do the following things:-
1. Scroll Down to the Internet Information Services (its below Indexing Services and above Microsoft .NET Framework 3.0)
2. Expand the tree next to Internet Information Services by clicking on the '+' sign.
3. Expand the IIS 6 Management Compatibility icon
4. Under that, make sure IIS Metabase and IIS 6 compatibility is Checked (Selected)
5. Since we havent checked (at least they arent checked by default) all the items, it (IIS 6 Management Compatibility) would be grayed (blue-filled)
6. Also select IIS 6 Management Console as checked
7. Similarly, under World Wide Web Services -> Application Development Features make sure the following are checked
i. .NET Extensibility, ii. ASP.NET, iii. ISAPI Extensions, iv. ISAPI Filters
8. The World Wide Web Services icon would also be a grayed (blue-filled) check box.
9. Once you un-expand these and go back to Internet Information Services, you would find that it is also grayed (blue-filled) checkbox.
10. Click Ok and it would take quite sometime to install ASP.NET 2.0 and also install the features selected and configure them.
Post these steps, you should be able to run Visual Studio 2005 under administrative priveleges (Right click, Run as Administrator) and also created websites hosted on http://localhost (IIS 7 Webserver) as against creating them on your local folder structure.
Here below are a few blog posts which give a Visual Step-by-Step instructions incase you are unable to follow the above
http://weblogs.asp.net/scottgu/archive/2006/09/19/Tip_2F00_Trick_3A00_-Using-IIS7-on-Vista-with-VS-2005.aspx
http://blogs.msdn.com/webdevtools/archive/2006/09/18/761206.aspx
Cheers !!!
In the earlier post, we saw the "Dynamic Data Website" shipped with ASP.NET 3.5 Extensions Preview that can be used for rapid application development of data driven websites using Visual Studio 2008.
The ASP.NET 3.5 Extensions Preview can be installed from here Once you install the same, you get a few things. One, is that you get the 'Dynamic Data Website' template I talked about earlier. The other thing is that you get the "ASP.NET 3.5 Extensions Website" template that allows you to create an ASP.NET 3.5 Website with the Extensions Preview features.
I know its confusing at this moment. If you read back, we released ASP.NET 3.5 and Visual Studio 2008 during the fag end of 2007. Along with that we also released an ASP.NET 3.5 Extensions Preview, a build that is currently a CTP where we are testing some of the new features that could be integrated as a part of SP1 for .NET 3.5 (and subsequently ASP.NET 3.5)
One of the features of the ASP.NET 3.5 Extensions is the Dynamic Data Controls that allows you to create Data Driven Websites using the LINQ to SQL and Dynamic Data Controls. The other feature is the ASP.NET 3.5 Extensions Website that allows you to create ASP.NET Website where you can use all the controls / features that are currently in preview.
Phew !!!
So, once you create this ASP.NET 3.5 Extensions Website, the first thing you would notice is that, the version of AJAX (System.Web.Extensions.DLL) is 3.6.0.0 as opposed to 3.5.0.0. that would be in the case of a normal ASP.NET 3.5 Web Site (File - New - Website - ASP.NET Website in Visual Studio 2008). Also you must be able to see a new tab in the toolbox reading "ASP.NET 3.5 Extensions". Some of the controls that would be present in this tab are the ListView, DataPager, UpdatePanel, UpdateProgress, Timer and the ScriptManager, ScriptManagerProxy controls. The version however, for these controls is again 3.6.0.0. which means that they would be the newer versions currently under preview. The other things that you would notice is the Dynamic Data Controls like DynamicListView, DynamicDetailsView, DynamicGridView and DynamicFormView. We will see about these controls in a later post.
The third set of controls you would notice are Silverlight and MediaPlayer controls which are very handy controls. The MediaPlayer controls allows you to play videos on your ASP.NET Pages without the need to do much work.
Lets start examining this. Open Visual Studio 2008, select "File - New - Website" andchose the "ASP.NET 3.5 Extensions Website"
Once you create the website, open the Default.aspx page and also expand the ASP.NET 3.5 Extensions Toolbox tab. Drag and Drop the MediaPlayer control to your webpage.
Next is that we need to add a Video to our site. Go to the root of the website and create a folder named "Videos" (We could do without this, but just a logical grouping). Add an existing video that you can pick up from your machine. By default, Windows Vista and Windows XP ships the Butterlfy.wmv and a couple of videos that you can use, in case you dont have any video on your machine. These files (Butterfly.wmv etc.,) are usually located in C:\users\<username>\videos\Sample Videos in case of Windows Vista and at C:\Documents and Settings\<user name>\My Documents\My Videos in case of Windows XP.
So you can add these videos or any other video that you have in your machine to the 'Videos' folder that we created in the root of the website.
Now, switch to design view of the Default.aspx page and select the MediaPlayer Control. You should see a "Silverlight" logo which indicates that the video would be hosted by Silverlight for the end users. Click on the smart tag that shows up next to the MediaPlayer control where you can set the MediaPlayer Tasks. Click on the browse button next to the Media Source TextBox to chose the video file. It currently supports File formats. You can chose a video of this file format from the 'Videos' folder that we created. You can alWMV, MP3, WMA and ASX so set it to Mute or AutoPlay and change other properties using the properties window.
Thats it! You are good to go and play Videos in your web page. The great advantage is that, this doesnt require the end users to have Windows Media Player to be installed since this would be powered by Silverlight. The end users just need ot install Silverlight runtime for the first time and with the flood of Silverlight applications that we are witnessing these days, there are more than likely chances that your end users have already Silverlight running in their machines. This means that you can play Videos on your ASP.NET Web pages without having any additional client installation.
For more information on further exploring MediaPlayer and creating chapters, check http://quickstarts.asp.net/3-5-extensions/silverlight/MediaPlayerControl.aspx
Cheers !!!
Earlier I had blogged about ASP.NET 3.5 Extensions Preview and also the Dynamic Data Controls and how ASP.NET would be evolving into a comprehensive platform for rapid applicaiton development of Data Driven Websites.
While the earlier preview I talked about (Dynamic Data Controls) was a part of the ASP.NET "Futures" CTP, there is now a much better build of the Dynamic Data Controls which we shipped as a part of ASP.NET 3.5 Extensions Preview.
Simply putting, we would encourage you to try out the new Dynamic Data Controls that were shipped as a part of ASP.NET 3.5 Extensions Preview rather than the one that was shipped with ASP.NET "Futures" July 2007 CTP.
So, if you are working with ASP.NET 3.5 and Visual Studio 2008, I would recommend you uninstall the ASP.NET "Futures" July 2007 CTP from "Add/Remove Programs" and install ASP.NET 3.5 Extensions Preview from ASP.NET Extensions Preview Website Once you install the same, you get a new "Dynamic Data Website" template, when you select "File - New - Website" in Visual Studio 2008. This one has a wizard icon attached to it, or occasionally has a blank icon, so you can easily distinguish this template from the old "Dynamic Data Website" template shipped with ASP.NET "Futures" July 2007 CTP, just in case you hadnt uninstalled the same.
Ok, once you select the new "Dynamic Data Website" and create a website, you will be seeing a bunch of files created automatically.
To begin with, we will just use the existing templates and create a Data bound website quickly. So, the first step in creating a Data Driven Website is to design the Data Access Layer. To do that, select "Add - New - Item" and choose "Linq to SQL Classes" and provide a name say "Northwind.dbml".
Once the Linq to SQL file is created, open Server Explorer, connect to your Database instance. Thereafter you can expand the "Tables" node and drag and drop a few tables into the Linq to SQL Visualizer.
Say, let us pick up the following tables
Products, Customers, Orders and Order_Details
The next step is just to build the solution and then your Data Access Layer built using LINQ to SQL is ready. You could customize, modify all the code that is auto generated using the file Northwind.designer.cs but make sure you take care that you dont regenerate this file since it would wipe off all your customizations.
The next step would be expanding your web.config file and locating the setting "enableTemplates" property of <dynamicData> tag to "true". Note that by default this is set to "false".
Thats it, you would be able to run the site and get the Default Page with a nice menu control linking to all the pages corresponding to the tables you had selected.
You could change the URL pattern, provide a different name, edit templates and do all other stuff with the auto-generated files and controls.
But to begin with, it provides you a full fledged funtional site with data in different formats, GridView, DetailsView, InsertTemplate, Filter etc., all of them AJAX Enabled. If you had worked with the Dynamic Data Controls of the earlier build (ASP.NET "Futures" July 2007 CTP) you would have noticed that all the controls used in that build are in much better shape and AJAX Enabled too.
Cheers !!!