Read or Write Session value on HTTP Handler file (.ashx)

Posted by Venkat | Labels: ,

How to use Session (ie: read or Write) on HTTPHandler file ie: .ashx file ?

I noticed some post on forums how to get the Session value on (.ashx file). So here is the solution.
By Default if you use Session on handler, the session returns null value. You have to implement the interface to read or write session value on handler file. If there is a situation to read Session value on your Handler file  implement IReadOnlySessionState.

When there is a case, you have to read or write session value in Handler file.
Implement IRequireSessionState.

Here is the code where i implement both IReadOnlySessionState and IRequireSessionState.

Example:

<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;
using System.Web.SessionState; 

public class Handler : IHttpHandler , IReadOnlySessionState  , IRequiresSessionState   {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}

Import XML file to Sql Server using SSIS

Posted by Venkat | Labels: ,

Good Morning to Everyone.

Today I am going to discuss about the SSIS (Sql server Integration Services) ie: how to Export the XML file to Sql Server with Column name and Data.

What is SSIS ?

 - To solve complex busniess problems.

 - sending and downloading files
 
 - sending email messages in response to events

 - Update Datawarehousing

 - Cleaning and Data mining

 - Managing Sql server data objects

Its the concept of ETL - ie. Extract - Transform - Load

Purpose:

1) Automate maintenance of sql server Database.

2) Update MultiDimensional Cube data as well.

I have the situation that xml file can be imported to the SQL server ie: i have the xml file look like this


<dataset>
<items>
 <empid>1</empid> 
 <empname>ela</empname> 
 <empcity>madhurai</empcity> 
 <empsalary>10000</empsalary> 
 </items>
 <items>
 <empid>2</empid> 
 <empname>arun</empname> 
 <empcity>chennai</empcity> 
 <empsalary>20000</empsalary> 
 </items>
 <items>
 <empid>3</empid> 
 <empname>kumar</empname> 
 <empcity>bangalore</empcity> 
 <empsalary>25000</empsalary> 
 </items>
 </dataset>

I have convert this XML file to DB tables. It should be same schema , contraints, Relationship, trigger etc..
For this SSIS is a easy way to convert any XML , text , Word , Excel file to Sql Database.

So you have to choose Business Intelligence and Development Studio (BIDS) to do the task

There are three ways to create a packages.

1) SSIS Designer(BIDS - Business Inelligence Development Studio)

2) API Programming

3) Import and Export Wizard

Here I am using the BIDS its a Graphical tool to create a packages, withoud need to write single line of code.

Open the new Project on Sql Server Integration Services.

Here is the steps to follow.

1. Create a new SSIS project in VS2005

2. Create a new data flow task - Double-click on the added task

3. Drag "xml source" from toolbox into data flow panel,Double Click on the XML

DataSource - a window opens select the xml file, and then generate XSD schema if not.

4. You could drag a "SQL Server detination" to the panel as data destination, connect XML source and SQL Server Destination, and use a new table.

Suppose if you getting Package Validation Error - Use the "data conversion" component in a data flow.
There may be the Datatype can be mismatched on Output columns. so at that time you can directly change the Datatype follow the below steps.

1. Right click the XML source->Show Advanced editor->Input and Output properties

2. Expand inputname->External Columns->Column name

3. On right panel, try to change the Datatype directly.

OR you could use "data conversion" component to convert the field that does not have the proper data type.
Finally if you check the DB it contains the New Table with the column Name and  its all Data available in the xml file.

Ref:

Validate Checkbox and Checkboxlist in easy way

Posted by Venkat | Labels: , ,

Hi Good Evening Techies.

I saw the post that has been asked number of times ie: how to validate the Checkbox and checkboxlist
so we can validate the Both of this using the Javascript or JQuery , but here I am going to make it much more easy ie: 4guysformula Provides the Control which can added to our toolbox then you can work these similar to the other validation Control

Validation Control for Checkbox and Checkboxlist

Go to the page down - Get the control ie: dll file ie: skmvalidators.dall place the file on Bin Folder of your project then add the dll file to your toolbox. then drag and drop to your aspx page & set some property thats it.

Alternatively Download the file here skmValidators.rar

AjaxHoverMenuExtender with ASP.NET

Posted by Venkat | Labels: ,

Today i am going to discuss, how to use AJAXHoverMenuExtender with ASP.NET. There are javascript available for onmouseover function which shows some text or something like menus. Today I am going to implement the same on serverside by using ajax functionality. There are number of tools available with ajax for our requirement I am going to use AjaxHoverMenuExtender - it show the menus or some text onmouseover of control or image or text.

First Create AjaxEnabled Website - so it automatically include AJAX Controls on your toolbox.

Place the ScriptManager on your page.
 <ajax:ScriptManager ID="ScriptManager1" runat="server">
        </ajax:ScriptManager>

Then Drag the Hyperlink and AjaxHoverMenuExtender on the Design page.
<asp:HyperLink ID="Hyperlink1" runat="server" Text="Session Mode"               NavigateUrl="~/Description.aspx"></asp:HyperLink>

 <ajaxToolkit:HoverMenuExtender ID="hme2" runat="Server" TargetControlID="Hyperlink1"
            PopupControlID="Panel1" PopupPosition="Center" OffsetX="-25" OffsetY="15"
/>

Main Properties of AjaxHoverMenuExtender

TargetControlID - Specify the server ControlID where you going to show the popup text.

PopupControlId -  Specify the ControlD which shows the popup while onmouseover of the

text of link.

PopupPosition - Center , Left , Right .

OffSetX , OffSetY - specify the X and Y position on that page according to the parent
Control.

Now i have to define the PopUp so this will be shown while mouseover.So here I used the panel which contains Datalist inside Where I bind the data from DB.

<asp:Panel ID="Panel1" runat="server" Width="600px">
            <asp:DataList ID="Dtl_Unit" CellPadding="1" CellSpacing="1"
ShowHeader="False" BorderWidth="0px"
                runat="server" DataKeyField="ServicesSubId" DataSourceID="Sqd_Unit" 

RepeatColumns="5">
                <ItemTemplate>
                    <table border="0">
                        <tr>
                            <td>
                                     <asp:HyperLink ID="Hyperlink2"  runat="server" 

NavigateUrl='<%#"Description.aspx?SId="+Eval("sessionmodeID") %>'
Text='<%#Eval("sessionmodeName")%>'></asp:HyperLink>
                            </td>

                        </tr>
                    </table>
                </ItemTemplate>
                <ItemStyle BorderWidth="0px"  />
            </asp:DataList>
            <asp:SqlDataSource ID="Sqd_Unit" runat="server" ConnectionString="<%$ 

ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT [sessionmodeID], [sessionmodeName] FROM 

[SessionTable]">
            </asp:SqlDataSource>
        </asp:Panel>

Output:

PayOffers.in