Posts

Showing posts from 2013

Encrypting/Decrypting web.config sections in ASP.Net

using System.Configuration; using System.Web.Configuration; public partial class _Default : System.Web.UI. Page { protected void Encripting_Click( object sender, EventArgs e) { EncriptSection( "appSettings" , "DataProtectionConfigurationProvider" ); } protected void Decripting_Click( object sender, EventArgs e) { DecriptSection( "appSettings" ); } // section name may be connectionStrings, appSettings private void EncriptSection( string sectionName, string provider) { Configuration config = WebConfigurationManager .OpenWebConfiguration(Request.ApplicationPath); ConfigurationSection section =config.GetSection(sectionName); if (section != null && !section.SectionInformation.IsProtected) { section.SectionInformation.ProtectSection(provider); config.Save(); ...

(Model view controller) MVC Interview questions and answers

http://www.codeproject.com/Articles/556995/Model-view-controller-MVC-Interview-questions-and#Is_MVC_suitable_for_both_windows_and_web_application

Split function in SQL Server

CREATE FUNCTION [dbo].[Split](@String varchar(MAX), @Delimiter char(1))       returns @temptable TABLE (items varchar(MAX))       as       begin         declare @idx int           declare @slice varchar(8000)           select @idx = 1               if len(@String)<1 or @String is null  return           while @idx!= 0           begin               set @idx = charindex(@Delimiter,@String)               if @idx!=0                   set @slice = left(@String,@idx - 1)               else                   set @slice = @String               if...

Chandra Bhushan Prasad: Your blood type & your personality

Chandra Bhushan Prasad: Your blood type & your personality : Blood Type A Facts: Roughly 34% of the world is A negative and 6% A positive.     Traits: Reserved calm, even tempered, introverted, ...

Your blood type & your personality

Blood Type A Facts: Roughly 34% of the world is A negative and 6% A positive.   Traits: Reserved calm, even tempered, introverted, sensitive to public opinion, responsible, reliable even tempered and takes charge when others are in confusion. May be introvert, standoffish or shy. May feel nervous or ill at ease with others. Sensitive to surroundings and other people. Hesitant to change. May feel misunderstood. Nature lover and prefers suburbs away from crowds. Needs a private space for refuge. May be accused of being a pessimist. Because of their fear of change many are artists or creative types due to sensitivity. Craves success. Speaking broadly, it is said that people with Type A Blood are calm, composed, very levelheaded and serious. They have a firm character, and are reliable and trustworthy (and hardheaded). They think things over and make plans deliberately, and they plug away at things steadily and assiduously. They try to make themselves more like their own ideal...

Chandra Bhushan Prasad: Chandra Bhushan Prasad: Example of Creating XML Fi...

Chandra Bhushan Prasad: Chandra Bhushan Prasad: Example of Creating XML Fi... : Chandra Bhushan Prasad: Example of Creating XML File Using T-SQL : SELECT (  SELECT 'ProjectID' AS ProjectID, 'ProjectName' ...

Chandra Bhushan Prasad: Example of Creating XML File Using T-SQL

Chandra Bhushan Prasad: Example of Creating XML File Using T-SQL : SELECT (  SELECT 'ProjectID' AS ProjectID, 'ProjectName' AS ProjectName FOR XML PATH('Project'), TYPE ) FOR XML PAT...

Chandra Bhushan Prasad: How to open a file (C#) as download option

Chandra Bhushan Prasad: How to open a file (C#) as download option : public static void DownloadFile ( string filePath ) {     string path = HttpContext . Current . Server . MapPath ( filePath );    ...

Chandra Bhushan Prasad: How to Set values to Session in Javascript

Chandra Bhushan Prasad: How to Set values to Session in Javascript : var session_value=' <% =Session[ " Test" ] %> '; alert(session_value);

Chandra Bhushan Prasad: Passing Eval from ASPX to Javascript function as P...

Chandra Bhushan Prasad: Passing Eval from ASPX to Javascript function as P... : <asp:LinkButton ID="lnkDocShow" runat="server" CausesValidation="false" OnClientClick='<%# String.F...

Chandra Bhushan Prasad: jQuery blur() Method

Chandra Bhushan Prasad: jQuery blur() Method : $("input").blur(function(){   alert("This input field has lost its focus."); });

Chandra Bhushan Prasad: How to convert filr into arrary of byte and save a...

Chandra Bhushan Prasad: How to convert filr into arrary of byte and save a... : //Convert file in arrary of byte String filepath = Server.MapPath(AsyncFileUpload1.FileName); byte[] FileByteStream = File.ReadAllBytes(f...

Chandra Bhushan Prasad: Show image loader with javascript in asp.net appli...

Chandra Bhushan Prasad: Show image loader with javascript in asp.net appli... : //Add button and called javascript function after click event. <div  id="divforhide">        <asp:Button ID="btnCl...

How to show loading image with javascript in asp.net application

//Add button and called javascript function after click event. <div  id="divforhide">        <asp:Button ID="btnClickMe" runat="server" Text="Click Me"          ValidationGroup="myvalidation" OnClick="btnClickMe_Click" OnClientClick="return    StartImageLoader('divforhide','divImageloader','myvalidation');" /> </div> //Add image loader <div  id="divImageloader">              <img src="../Images/myimageloader.gif" />  </div> //Add java script to show hide loader----- function StartImageLoader(btnID, image, validationGroup) {             var flag = Page_ClientValidate(validationGroup);             var divctrl = document.getElementById(btnID);           ...

How to convert filr into arrary of byte and save again it in file.

//Convert file in arrary of byte String filepath = Server.MapPath(AsyncFileUpload1.FileName); byte[] FileByteStream = File.ReadAllBytes(filepath) //Save arrary of byte into file. public void SaveFileFromBytes(string FileName, byte[] FileByteStream)         {             FileStream targetStream = null;             Stream sourceStream = new MemoryStream(FileByteStream);             string uploadFolder = @"~\MyDestinationFolder\";             System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(Server.MapPath(uploadFolder));             if (!dir.Exists)                 dir.Create();    ...

jQuery blur() Method

$("input").blur(function(){   alert("This input field has lost its focus."); });

Passing Eval from ASPX to Javascript function as Parameter

<asp:LinkButton ID="lnkDocShow" runat="server" CausesValidation="false" OnClientClick='<%# String.Format("javascript:return DownloadMyFile(\"{0}\")", Eval("Field1").ToString()) %>'  CssClass="commiicondown"  Text='<%# Bind("Field2") %>'></asp:LinkButton> <script type="text/javascript" language="javascript">          function DownloadMyFile(Document) {              window.open('abcd.aspx?Document=' + Document, '_self', false)          }     </script>                                                          ...

How to Set values to Session in Javascript

var session_value=' <% =Session[ " Test" ] %> '; alert(session_value);

How to open a file (C#) as download option

public static void DownloadFile ( string filePath ) {     string path = HttpContext . Current . Server . MapPath ( filePath );     System . IO . FileInfo file = new System . IO . FileInfo ( path );     if ( file . Exists )     {         HttpContext . Current . Response . Clear ();         HttpContext . Current . Response . AddHeader ( "Content-Disposition" , "attachment; filename=" + file . Name );         HttpContext . Current . Response . AddHeader ( "Content-Length" , file . Length . ToString ());         HttpContext . Current . Response . ContentType = "application/octet-stream" ;         HttpContext . Current . Response . WriteFile ( file . FullName );         HttpContext . Current . Response . End ();     } }

Example of Creating XML File Using T-SQL

SELECT (  SELECT 'ProjectID' AS ProjectID, 'ProjectName' AS ProjectName FOR XML PATH('Project'), TYPE ) FOR XML PATH(''), ROOT('MyProjectXML')