Archive for the ‘ASP.NET’ Category
If same issue occurs in an ASP.NET 3.5 SP1 application, you can use the StopRoutingHandler class which implements the IRouteHandler interface.
I have been working on creating some .NET dlls at work which would commonly be utilized by our web applications. And, one of the requirements was getting the connection string information from web.config file. Simply making the call by using the ConfigurationManager class wouldn’t work since it was giving some kind of compile time error when you try to build the dll. So, I needed to find a workaround to retrieve the connection string from either connectionStrings or appSettings elements. Here is the solution that I have figured out so far.
Generic function that grabs the information based on your connection string name:
To understand the ConnectionStringSettingsCollection and NameValueCollection classes, followings links would be helpful:
While I was reading my feed aggregator at the weekend, I was paid attention to the recent post from Encosia because of its title. Validating a username asynchronously would be a great functionality in almost every types of online registration scenarios. Right after reading the post, I downloaded the binary file from CodePlex and created a very simple demo in about half an hour. That was really easy to implement.
Before starting to code, be sure that the dll that is downloaded from CodePlex is in the Bin directory:
My sample (yes, very simple) registration form is:
As it can be seen, the trick is with the ServicePath and ServiceMethod attributes. ServicePath is the path to the webservice housing the ServiceMethod, and ServiceMethod is the method checking the availability of a username. My sample (yes, again very simple) webservice is:
Details of other attributes of the control can be read via its Discussions page at CodePlex.
Finally, here is how the form looks like after all these implemenations:
You can download this sample registration form from here.
I would encourage to write your comments to here if you face any issues about the control.
When the July 2008 CTP of Live Tools were released a few weeks ago, I was kind of impressed with the Map control. I finally had a chance yesterday to read more about it and develop my own simple testing page. You may need to download this CTP release first before reading the rest of this post.
Here is the 5 steps to implement this control into any ASP.NET page:
1. When you create a new website, select “ASP.NET Windows Live Web Site” as a template:
2. Be sure that “Microsoft.Live.ServerControls.VE.dll” is in the Bin directory:
3. Be sure that “Virtual Earth” tab is in the Toolbox:
4. Drag the “Map” control and drop it into the ASP.NET page, and play around with some of the attributes in it:
5. Press the magic key (F5) to build and view the sample page:
This sample can be downloaded via here.
• I strongly suggest reading the original post first before passing to the rest of this post.
Implementing The Original Post…
As a data source, I just grabbed the XML file that I used before in here, and simplified it.
Here is the CSS implementation of the original post into my sample ASPX page:
And then, I created the DIVs programmatically by using a ListView as in the following:
As a result of this, I organized the Page_Load event as:
You can download the sample application via here.
I have recently figured out that if there is a scrollbar’ed Panel control inside an UpdatePanel, it looses its scrollbar position after any type of partial postback within that UpdatePanel. There can be a GridView, a DIV container or another similar control instead of this Panel.
I have searched and found some workarounds at ASP.NET forums, and this specific one was the easiest one to implement into every situation in order to gain back the position of scrollbar. I enhanced it a bit by handling null cases and using the ClientID property. Here is the result:
DataPager is one of the new controls in ASP.NET 3.5, and it provides paging functionality for data-bound controls that implement the IPageableItemContainer interface, which is only the ListView control for the time being.
By default, DataPager has two commonly used paging styles:
• Numeric Pager via NumericPagerField
• Next and Previous Pager via NextPreviousPagerField
To get an idea about how to implement these basic common styles, you can read this post.
This post will explain how to enhance the paging experience in a ListView by using both a NextPreviousPagerField and a DropDownList which will enable users to select the page size of ListView. This page size is actually the PageSize property of the DataPager, and this property defines the number of records that are displayed for each page of ListView.
To avoid complexity, the following simple XML file (Contacts.xml) will be used as a data source:
And, the XMLDataSource that consumes this XML file is:
“xdsDemo” is the DataSourceID of the ListView “lvDemo”:
After getting this data binding done, LayoutTemplate of “lvDemo” should be similar to the following:
Even though it is not completely related with the topic and emphasis of this post, ItemTemplate and AltenatingItemTemplate templates of “lvDemo” are:
Finally, here is the code that sets DropDownList (ddlDemo) and DataPager (dpDemo):
As a conclusion of all these things, the result on the browser should be like:
Sample code for this demo application can be downloaded via here.