SQL In clause in LINQ (In LINQ operation like SQL In clause)

Hello Frd's

There are most of situation arise when we required to used IN clause of sql in our LINQ technology.

But LINQ not directly provide IN clause.We have to manage it another way.Below are simple example which do same thing.(SQL IN Clause in LINQ Technology)

  public static string[] GetOpenStatusIDListForInQueryLinq()  
       using (ITILDataContext context = new ITILDataContext(Common.ConnectionString))  
         //operation which return list of all id as string array  
 // below method perform Count Operation using IN query in LINQ  
 public static int Perfrominoperation()  
       using (ITILDataContext context = new ITILDataContext(Common.ConnectionString))  
         var incidentobj = from incident in context.AllIncidents  
                  where GetOpenStatusIDListForInQueryLinq().Contains(incident.StatusID.ToString())  
                 select incident;  
         return incidentobj.Count();  
 //Above function return all Records which have a iD resides in a String array and same id  
 resides in a Tabke of AllIncidents  

If you have any question or any suggestion please write in comment.

Enjoy !!!!!!!

Posted in | 3 comments

LINQ to SQL :- Importent Method OnValidate

LINQ to SQL :- Importent Method OnValidate

OnValidate is good method in linq to sql technology.

This Method allow to Do validation or set default entry which you want to do before Insert,Update or Delete.

Example of Such uses are :-

1.) Set Default Value While performing DML operation.

2.) If you want to Check Duplication Inserting then u can perform it here.

3.) While keeping autodelte,autoinserting,autoupdating u can perform any operation which required before insert,update or delete.

Posted in | 0 comments

Convert HTML to Word Document using ASP.Net (C#)

Hello Frd's

Find Below code to Convert HTML to Word Document using ASP.Net (C#).

     HttpContext.Current.Response.Charset = "";  
     HttpContext.Current.Response.ContentType = "application/msword";  
     string strFileName = "GenerateDocumentfgfgfg" + ".doc";  
     HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);  
     StringBuilder strHTMLContent = new StringBuilder();  
     -- RadEditor1.Content is HTML Text  I m taking it from editor.

If you have any question write in comment box.

Enjoy !!!!!

Posted in | 15 comments

Convert Word Document to HTML using ASP.Net (C#)

Hello Frd's

Find Below Code to Convert Word Document to HTML using ASP.Net (C#).


Variable Declaration :-

     protected Microsoft.Office.Interop.Word.ApplicationClass objWord = new      
    protected string strPathToUpload; //Path to upload files "Uploaded"
    protected string strPathToConvert; //Path to convert uploaded files and save
    object fltDocFormat = 10; //For filtered HTML Output
    protected object missing = System.Reflection.Missing.Value;
    protected object readOnly = false; //Open file in readOnly mode
    protected object isVisible = false;//The process has to be in invisible mode

Actual Method :-

       //To check the file extension if it is word document or something else  
       string strFileName = fUpload.FileName;  
       string[] strSep = fUpload.FileName.Split('.');  
       int arrLength = strSep.Length - 1;  
       string strExt = strSep[arrLength].ToString().ToUpper();  
       //Save the uploaded file to the folder  
       strPathToUpload = Server.MapPath("Upload");  
       //Map-path to the folder where html to be saved  
       strPathToConvert = Server.MapPath("Upload");  
       object FileName = strPathToUpload + "\\" + fUpload.FileName;  
       object FileToSave = strPathToConvert + "\\" + fUpload.FileName + ".htm";  
       if (strExt.ToUpper().Equals("DOC"))  
         fUpload.SaveAs(strPathToUpload + "\\" + fUpload.FileName);  
         lblMessage.Text = "File uploaded successfully";  
         //open the file internally in word. In the method all the parameters should be passed by object reference  
         objWord.Documents.Open(ref FileName, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing, ref missing);  
         //Do the background activity  
         objWord.Visible = false;  
         Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;  
         oDoc.SaveAs(ref FileToSave, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);  
         lblMessage.Text = fUpload.FileName + " converted to HTML successfully";  
         lblMessage.Text = "Invalid file selected!";  
       //Close/quit word  
       objWord.Quit(ref missing, ref missing, ref missing);  
     catch (Exception ex)  

If you have any question post in comment.

Enjoy !!!!!

Posted in | 1 comments

Configure your website to use Membership provider feature.

***   Configure your website to use Membership provider (aspnet_membership) feature ***.

Asp.net provides facility for inbuilt membership management and roles management.  You find many article on it on google I am not going on details about t. but here I am discuss how to apply membership in out asp.net web application or web site

First you need to run below script. Download it and run in your database.

Namespace: -    System.Web.Security  you have to include this namespace to use all method of aspnet membership provider.
Second you need to change your web.config section. Add below section in your web.config section.

(This will make your website Form Authentication Mode and Apply all setting which aspnetmembership required.)

<authentication mode="Forms">
                  <forms name="login" loginUrl="Login.aspx" defaultUrl="Default.aspx" protection="All" cookieless="UseCookies" path="/" timeout="600000">

                  <deny users="?"/>
            <membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="15">
                        <add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="defaultConnection" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="HelpdeskApplication" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" passwordFormat="Clear" minRequiredNonalphanumericCharacters="0"/>
            <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="SqlRoleProvider" cookieName=".ASPXROLES" cookiePath="/" cookieTimeout="30" cookieRequireSSL="false" cookieSlidingExpiration="true" createPersistentCookie="false" cookieProtection="All">
                        <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="defaultConnection" applicationName="HelpdeskApplication"/>

Now you can use all Feature of memmbership Provier. Below are some basic methods which are used.
1.  CreateUser  :- Createuser method used to create a new user.

Membership.CreateUser Method (String, String)

MembershipUser user = Membership.CreateUser(UserId, password, email);

You not nees to write any other code. It’s manage by .net frame work.

2.       MembershipUser user = Membership.GetUser(“userid”);
This method used to get all created member information.

3.       Membership.DeleteUser(UserId, true);
This method used to delete specific userid from a database. Second argument used to delete all related records or not.

4.       RoleProvider.CreateRole
This method is used to create a new role.

5.  Roles.AddUserToRole

This method is used to assign role to user.
Roles.AddUserToRole("username", "roles");

6.  Roles.AddUsersToRole
This method used to assign several user to one role.
      new string[] { "username1", "username2" }, "Roles");
7.       MembershipProvider.ChangePassword
This method is used to update password for user.

Enjoy !!!!  if you have any query then  let me know......

Posted in | 0 comments

how to make website for multi Language support in asp.net (Resource Example in asp.net)

Hello Frd's

Here i am going to dicuss how to make multi support language in a asp.net.

In a asp.net multi support language supported build using resources.

there are two type of resouce in asp.net global resource and  local resource we will dicuss resources later.

to build multi language support in a asp.net there are two classes are use :-

1. Culture  and 2. UICulture.

Culture providing information related to Datetime,currency etc..  setting ofr multi langugaes. while UICulture are related to UI that means it's deal with a resources.

to set specified language in a web site you can give culturre setting in a globally web.config

< globalization uiCulture="es" culture="es-MX" / >"
Now lets see how to set multi language support from code behind.
Lets take one example :-
First Create One page Default2.aspx and suppose we want two language support in our application
Suppose English and Swedish language. 
So create resource for both in a local resource.

hear kepp in mind the resources name and extension.
currently for English there are resource name is same as a page name.

Page name :- Default.aspx
Resource file Name :- Default.aspx.resx
For Swidden language.
Resource file Name :- Default.aspx.sv.resx

Now lets put one label on a page. and set meta:resourcekey

Now you have to set culture in  Page_PreInit of a page. For better utilization you defaine it in a One base Page and Imherit other page from this basepage.

Where en-US  values for English / United states some other language are as below.

Language = "German" Value="de-DE"

Language ="Spanish" Value="es-ES"

Language ="Swedish" Value="sv-SE"

Language ="United States - English" Value="en-US"
Now lets run the application

Now lets apply second langugae swidden.


Hop you getting.

if you hasve any query let me know

Enjoy !!!!!!!!!!!!!

Posted in | 1 comments