2011年11月8日星期二

How to create ASP.NET Membership database

1. On the SQL server, create an empty database, say "ASPUserDB".

2. Run aspnet_regsql.exe from C:\windows\Microsoft.NET\Framework\v4.0XXX (or whatever version).

3. Follow the wizard and select the database that has been created in Step 1.

2011年11月7日星期一

ASP.NET Menu Control rendering problem in Chrome


<asp:Menu ID="NavigationMenu" runat="server" Orientation="Horizontal" />

The default layout setting of Menu control will rendering a blank row on top of the menu item which looks like extra padding. This happens to Google Chrome.


To get rid of this, just set SkipLinkText value to ""(empty string):



<asp:Menu ID="NavigationMenu" runat="server" Orientation="Horizontal" SkipLinkText="" />

For more details, please read:

ASP.NET Menu Control Accessibility Feature renders incorrectly in Safari and Chrome Browsers.


2011年8月9日星期二

Bind data to DropDownList in edit template of GridView or DetailsView

This is straight forward. Set the “SelectedValue” attribute for DropDownList control.

Note. The “SelectedValue” is not in the intelligent context menu. It won’t automatic pop-up when you typing, but it does exist.

For example, we display a product in a DetailsView. In edit mode, we want to use a dropdown list to select the type of that product. Assume the type id is used in the product table, the edit template would be like:

<EditItemTemplate>
<asp:DropDownList  **** DataTextField="Name" DataValueField="typeid" SelectedValue='<%# Bind("typeid") %>'></asp:DropDownList>
</EditItemTemplate>

This will auto bind the type id to the list and update with the selected id. The update command and parameters are as usual.

2011年4月30日星期六

Siderite's Blog: Invalid postback or callback argument in ASP.Net 3.5

origin: Siderite's Blog: Invalid postback or callback argument in ASP.Net 3.5

Also, you might get a Sys.WebForms.PageRequestManagerServerErrorException with code 500 when using Ajax. It usually happends when you click on a button in a GridView or another bound control. You expect it to work, but it doesn't, even if the code is relatively clear.

The answer is (probably) that you are binding the container bound control every time you load the page (instead of only on !IsPostBack). The thing is this used to work in ASP.Net 2.0.

Bottom line: check your binding, see if you are not doing any DataBind in between the button click and the eventual event catch.