tirsdag den 22. september 2015

Adding filetypes to IIS

Sometimes we need to create JSON in a text file with extension .json, however by default IIS 7 or any of the IIS are not configure to handle .json extension. So below is a very simple method to do that. You can apply the method on the root of IIS so .json can be handled by every site or virtual folder in the IIS or just to the specific site.
  1. Open IIS Manager (run --> "inetmgr")
  2. Display properties for the IIS Server
  3. Click MIME Types and then add the JSON extension:
    • File name extension: .json
    • MIME type: application/json
  4. Go back to the properties for IIS Server
  5. Click on Handler Mappings
    • Add a script map
    • Request path: *.json
    • Executable: C:\WINDOWS\system32\inetsrv\asp.dll
    • Name: JSON

http://www.uipress.com/add-json-handler-support-in-iis-7/

mandag den 8. juni 2015

Sql select statement where is empty null

  1. <%@ Page Language="C#" AutoEventWireup="true" %>  
  2.   
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  4. <script runat="server">  
  5.       
  6. </script>  
  7. <html xmlns="http://www.w3.org/1999/xhtml" >  
  8. <head id="Head1" runat="server">  
  9.     <title>Using CancelSelectOnNullParameter property in SqlDataSource in asp.net</title>  
  10. </head>  
  11. <body>  
  12.     <form id="form1" runat="server">  
  13.     <div>  
  14.         <h2 style="color:Navy; font-style:italic;">SqlDataSource Example: using CancelSelectOnNullParameter Property</h2>  
  15.         <asp:SqlDataSource   
  16.             ID="SqlDataSource1"  
  17.             runat="server"  
  18.             ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
  19.             SelectCommand="Select CategoryID, CategoryName From Categories"  
  20.             >  
  21.         </asp:SqlDataSource>  
  22.         <asp:DropDownList   
  23.             ID="DropDownList1"  
  24.             runat="server"  
  25.             DataSourceID="SqlDataSource1"  
  26.             DataValueField="CategoryID"  
  27.             DataTextField="CategoryName"  
  28.             AppendDataBoundItems="true"  
  29.             AutoPostBack="true"  
  30.             >  
  31.             <asp:ListItem Text="All" Value=""></asp:ListItem>  
  32.         </asp:DropDownList>  
  33.         <asp:SqlDataSource   
  34.             ID="SqlDataSource2"  
  35.             runat="server"  
  36.             ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
  37.             SelectCommand="Select ProductID, ProductName, QuantityPerUnit, UnitPrice From Products Where CategoryID=IsNull(@CategoryID, CategoryID)"  
  38.             SelectCommandType="Text"  
  39.             CancelSelectOnNullParameter="false"  
  40.             >  
  41.             <SelectParameters>  
  42.                 <asp:ControlParameter   
  43.                     Name="CategoryID"   
  44.                     ControlID="DropDownList1"   
  45.                     PropertyName="SelectedValue"  
  46.                     ConvertEmptyStringToNull="true"  
  47.                     />  
  48.             </SelectParameters>  
  49.         </asp:SqlDataSource>  
  50.         <asp:GridView   
  51.             ID="GridView1"  
  52.             runat="server"  
  53.             DataSourceID="SqlDataSource2"  
  54.             AutoGenerateColumns="true"  
  55.             AllowPaging="true"  
  56.             PageSize="10"  
  57.             BorderColor="Snow"  
  58.             Font-Names="Comic Sans MS"  
  59.             Width="650"  
  60.             >  
  61.             <HeaderStyle   
  62.                 BackColor="DarkGoldenrod"   
  63.                 BorderColor="PeachPuff"   
  64.                 ForeColor="Snow"   
  65.                 Height="45"/>  
  66.             <RowStyle   
  67.                 BackColor="Chocolate"   
  68.                 ForeColor="Snow"   
  69.                 Font-Italic="true" />  
  70.             <PagerStyle   
  71.                 Height="45"   
  72.                 HorizontalAlign="Right"   
  73.                 BackColor="OrangeRed"  
  74.                 Font-Bold="true"  
  75.                 Font-Size="X-Large"  
  76.                 ForeColor="Snow"  
  77.                 />  
  78.             <PagerSettings Mode="Numeric" />  
  79.         </asp:GridView>  
  80.     </div>  
  81.     </form>  
  82. </body>  
  83. </html>  

http://asp-net-example.blogspot.in/2009/10/using-cancelselectonnullparameter.html