Archive for the ‘asp.net’ Category
Custom Parameters with ObjectDataSource and SqlDataSource
Found a decent article about custom parameters for data sources in ASP.NET. It was written by Eilon Lipton who has been on the ASP.NET team for quite a while at Microsoft. The article discuss how to insert your own custom parameters and has easy examples and a good explanation.
GridView with DropDownList – Server tag is not well formed.
Ran across an issue today when trying to get my DropDownList embedded within a GridView. Here is an extract of the code (the error is in the red text):
<ItemTemplate>
<asp:DropDownList
ID="ddlMaker"
runat="server"
DataSourceID="odsMakers"
DataTextField="makerName"
SelectedValue="<%#Bind("MakerID") %>"
DataValueField="makerID">
</asp:DropDownList>
</ItemTemplate>
When I compiled I received an error “The server tag is not well formed.”
After a bit of trial and error I realized it was because there were quotes nested within quotes. To make this work all that had to be done was to change the outside double quotes on the SelectedValue parameter to be single quotes as shown below.
<ItemTemplate>
<asp:DropDownList
ID="ddlMaker"
runat="server"
DataSourceID="odsMakers"
DataTextField="makerName"
SelectedValue='<%#Bind("MakerID") %>'
DataValueField="makerID">
</asp:DropDownList>
</ItemTemplate>
Hope I saved someone a bunch of wasted time.
ASP.NET AJAX Control Toolkit Samples
Most of you probably have already experimented with the Control Toolkit, but just in case you never ran across it, take a look at these Toolkit samples
If you have any questions about them, drop me a comment here.
Useful way to reformat an ASP.NET File Upload control
The guys over at QuirksMode.org have come up with an interesting way to get around the default styling of a File Upload control See the details here:
http://www.quirksmode.org/dom/inputfile.html
ASP.NET Session State in SQL Server
There are lots of places to get information about putting the Session State into a SQL Server database instead of in-memory. The information I have found most useful is the utility aspnet_regsql.exe. It performs a bunch of different tasks for ASP.NET and interaction with SQL Server and the membership interfaces.
For example if you want to get session persisted across SQL Server reboots you can issue this command:
aspnet_regsql.exe -ssadd -sstype p -E -S <servername>
The sstype p is the option that allows for the state to be persisted. You can execute aspnet_regsql.exe -?
Disabling buttons on click for ASP.NET forms
Found some great tips in the simple-talk.com blog about disabling buttons on asp.net forms.
If you ever created a form and had your users click on the submit button multiple times this is the code you have been looking for. Be sure to check out Robyn Page’s comments for a method to block the whole form during the form submit as well.
Complete details can be found here.