Posts

Programmatically Zip and UnZip the files in .NET

Normally we may find the functionality to Zip and Unzip the file pro grammatically.We have many third party components to do this operation.Here I am going to present Zip and Unzip files using "CGZipLibrary.dll" in C#.NET. To do this we need to download the CGLibrary.dll from this link and register this dll. The zip file contains 3 DLL's: CGZipLibrary.dll zip32.dll Unzip32.dll Open the command prompt in administrator mode.Now we need to register this CGZipLibrary.dll as given below regsvr32 filepath\filename Ex : regsvr32 D:\Download\CGLibrary.dll After registering the dll and Copy zip32.dll and unzip32.dll to c:\windows\system32 directory or c:\winnt\system32. Unzip the file you need to do like this            string SrcPath = @"D:\StudentReports.zip";             string DestPath = @"D:\ZippedFiles";          ...

Bind the Events to the Dynamically Created Rows in a HTML Table

I found a solution to bind the events to the dynamically created buttons in a HTML.Some times we need to add a row to the existing HTML table with some inputs.That dynamically created row is not visible in the page source.Try It ! So to attach the events also we need to do like this var newRow = " <tr> <td></td> <td><input type='text' id='tbNameDyn'/></td> <td> <input type='text' id='tbAgeDyn'/>< /td> <td><input type='checkbox' id='tbResultDyn'/></td> <td > <input type='submit' name='submitButton' value='Save Row' id='btnSaveRowDyn' onclick='DynButtonClick();'> </td></tr> " ; // $('#webgrid > tbody:last'). $ ( '#webgrid tbody:last' ) . append ( newRow ) ; Here I have binded the button with the event "onClick" function ...

Make the Textbox as Label using CSS

This is a simple tip to make the textbox as label in the Web Pages.We need to just add a simple CSS to the input text.See code snippet . textboxAslabel { border : none ; background-color : # FFF ; border-color : # FFF ; } Here I have mentioned the background-color and border-color as "white".In my application the background-color is white.So according to your background-color change it.Now Apply that to the textbox.See this Image

Single to handle multiple "Submit" button Clicks in MVC3 Razor View

Last week, I have faced a problem on handling the multiple "Submit"   buttons clicks in a View.I am not very good at MVC3 but I want to share my experience so that others can find some solution regarding this problem. Suppose we have many Submit buttons in a View where we want to handle the different functions. In the Controller of the We need to write the Code for different submit buttons as given below [ AcceptVerbs ( HttpVerbs . Post ) ] public ActionResult FormActions ( string submitButton ) { switch ( submitButton . ToLower ( ) ) { case " click to know date " : this . SetNotification ( DateTime . Now . Date . ToString ( " dd-MMM-yyyy " ) ,   NotificationEnumeration . Success , true ) ; return View ( " index " ) ; break ; case " click to know time " : ...

Difference between the SCOPE_IDENTITY(),@@IDENTITY and IDENT_CURRENT in Sql Server

SCOPE_IDENTITY(),@@IDENTITY and IDENT_CURRENT('table_name') are the SQL SERVER Functions which will return the last inserted record Identity Value. Normally in the development stage we need to get the last inserted row information using SQL Query. Lets go in deep to understand the differences between these three functions. @@IDENTITY : @@IDENTITY will return the Identity value generated in a table irrespective of the scope.The main advantage lies here when we have a trigger on a table that causes anidentity to be created in another table,you will get the identity that was created last since it gets the identity regardless of the table. Syntax : SELECT @@IDENTITY; SCOPE_IDENTITY(): SCOPE_IDENTITY() also returns the Identity Value generated in a table with in the same scope regardless of the table that produced the value. Syntax: SELECT SCOPE_IDENTITY(); IDENT_CURRENT('table_name'): It will returns the last Identity value produced in a table regardle...

Set the Default Value to the Column Of a Table Programmaticaly

Normally we face this type of problem when we want to set the column default value pro-grammatically. To Solve this problem we need to first get the table column information using this Query. "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='person'" . Here the table name may vary. when we execute this Query we will get the each column information . So based on this we can Iterate the each column and get the each column Information as given below        VB.NET  Private Sub Initialise_The_Table(ByVal ReqTab As String) On Error GoTo handle_error Dim eachTableAdapter As SqlDataAdapter Dim tableDataset As New DataSet Dim adoHelper As SQLHelper = SQLHelper.GetInstance eachTableAdapter = adoHelper.GetAdapter("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + ReqTab + "'") eachTableAdapter.FillSchema(tableDataset, SchemaType.Source, ReqTab) eachTableA...

Context Menu in ASP.NET

Image
We normally face a task like to show Menu when we right click the gridview or treeview e.t.c. Many third party controls are providing this right click context Menu to the controls like one of the best third party control like Telerik . But we can do this type of requirements using jQuery also. To do this in ASP.NET we need to download the jQuery Context Menu plugin. We need frame the menu div based on our requirement.See this example to do < div >      < ul id ="myMenu" class ="contextMenu" >        < li class ="edit" >< a href ="#edit" > Edit Node </ a > </ li >        < li class ="delete" >< a href ="#delete" > Delete Node </ a > </ li >      </ ul >    </ div > * This source code was highlighted with Source Code Highlighter . After downloading the plugin you need to add this l...