Posts

Showing posts from 2013

How to access master page variable/property from the content page using C#

======== MASTER PAGE CODE BEHIND public string MasterPageVariable { get ; set ; } ========ASPX PAGE Source <% @ MasterType VirtualPath ="Maste Page Path" %> ========ASPX PAGE Code Behind protected void Page_Load( object sender, EventArgs e) { Master.MasterPageVariable = "This text is written from Content page." ; }

How to enable/disable dropdownlist through a checkbox selection using Jquery

============Head Tag Of Page================== < script src ="Scripts/jquery-1.4.1.js" type ="text/javascript" ></ script > <script type= "text/javascript" > $(document).ready( function () { $( "#chkbox" ).click( function () { if ( this . checked ) $( '#ddlcountry' ).attr( 'disabled' , 'disabled' ); else $( '#ddlcountry ' ).removeAttr( 'disabled' ); }); }); </ script > ==================Body Tage of Page================= < asp:CheckBox ID ="chkbox " runat ="server" Text ="Enable/Disable" /> < asp:DropDownList ID ="ddlcountry " runat ="server" > < asp:ListItem Text ="Select" Value ="India"/ > < asp:ListItem Text ="Opt...

Enable the file upload in ck-editor using C#

==========Add the following script in head tag================  <script type="text/javascript" language="javascript">     $(function () {         CKEDITOR.replace('<%=CKEditorControl1.ClientID %>', { filebrowserImageUploadUrl: 'Upload.ashx' });     });   </script> =========Create ASHX handler page for uploading================= <%@ WebHandler Language="C#" Class="Upload" %> using System; using System.Web; public class Upload : IHttpHandler {          public void ProcessRequest (HttpContext context) {         databaseprocess db = new databaseprocess();                 string appLink = "Web Site URL";         HttpPostedFile uploads = context.Request.Files["upload"];         string CKEditorFuncNum = context.Request["CKEditorFuncNum"];         string ...

Lightbox is a simple script used to overlay images Using Jquery

Image
Download the Running Example From Following URL http://lokeshdhakar.com/projects/lightbox2/

Replace Double Quote with Empty String using C#

string strvariable="Frame size 7" x 12" inches";  string result = strvariable.Replace("\"", ""); ==============Answer================= Frame size 7 x 12 inches

How to calculate Shipping by UPS using C#

First Create a class for UPS shipping "UPS.cs" using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.IO; using System.Net; namespace UPSShipping {     public class UPS     {         private string m_accessNumber;         private string m_userName;         private string m_password;         private string m_shipperNumber;         private string m_pickupType;         private string m_uri = "https://www.ups.com/ups.app/xml/Rate?";         #region Properties         public string AccessNumber         {             get { return m_accessNumber; }             set { m_accessNumber = value; }         }       ...

How to get URL’s & Querystrings using jQuery

URL = http://www.domain.com/post.aspx?postid=39&posttype=General 1. Get the current URL in jQuery var currentURL = document.URL; Result : http://www.domain.com/post.aspx?postid=39&posttype=General ------------------------------------------------------------------ var currentURL = window.location.href; Result : http://www.domain.com/post.aspx?postid=39&posttype=General ------------------------------------------------------------------ 2.Get the pathname var currentURL = location.pathname; Result : post.aspx?postid=39&posttype=General ------------------------------------------------------------------ 3.Get the hostname var currentURL = location.hostname; Result : www.domain.com ------------------------------------------------------------------ 4.Get A URL Hash Parameter var currentURL = location.hash; Result : null ------------------------------------------------------------------ 5.Read Querystring Parameters function GetQueryStringParams(sPar...

How to populate radio button through jquery

A radio buttons group, with a name=”sex”.... <input type="radio" name="sex" value="Male">Male</input> <input type="radio" name="sex" value="Female">Female</input> <input type="radio" name="sex" value="Unknown">Unknown</input> --------------------------------------------------------------------------------------------- 1. To display the selected radio button value. $('input:radio[name=sex]:checked').val(); --------------------------------------------------------------------------------------------- 2. To select a radio button (Male). The radio button is 0-based, so the ‘Male’ = ’0′, ‘Female’ = ’1′ and ‘Unknown’ = ’2′. $('input:radio[name=sex]:nth(0)').attr('checked',true);                             OR $('input:radio[name=sex]')[0].checked = true; -----------------------------------------------------------------...

How to Bind-Get-Set value to dropdownlist using jquery

1. Add an option to list:  $("<option value='0'>Select</option>").appendTo("#ddlCategory"); -------------------------------------------------------------------------- 2. Remove all the Options from drop down: $("#ddlCategory> option").remove(); -------------------------------------------------------------------------- 3. Get the selected item Text: $("#ddlCategory option:selected").text(); -------------------------------------------------------------------------- 4. Get the selected item Value:  $("#ddlCategory").val(); -------------------------------------------------------------------------- 5. Set the item by Value: $("#ddlCategory").val(2); -------------------------------------------------------------------------- 6. Selection change event: $("#ddlCategory").change(function(e)  {     //do your work });   and here goes populating a dropdown through jquery..... ...

How to Disable DropDown List Item using jQuery

To disable any item, just need to add attribute "disabled" with value "disabled" to the list item. //Code Starts $(document).ready(function() {           $("#ddlList option[value='jquery']").attr("disabled","disabled"); });​ //Code Ends You can also disable item by their Text, not by value. Below jQuery code will disable the List Item with text "HTML" //Code Starts  $(document).ready(function() {      $('#ddlList option:contains("HTML")').attr("disabled","disabled"); });​ //Code Ends

How to dynamically change the content in the Fckeditor with JavaScript

============= Function For Get Content function getEditorValue( instanceName ) { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance( instanceName ) ; // Get the editor contents as XHTML. return oEditor.GetXHTML( true ) ; // "true" means you want it formatted. } ============= Function For Set Content function setEditorValue( instanceName, text ) { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance( instanceName ) ; // Set the editor contents. oEditor.SetHTML( text ) ; }

How to get content of Ckeditor & Fckeditor using Javascript

CKEDITOR: To get content of ckeditor we will create object of ckeditor and then we will provide id of textarea that is replaced by ckeditor. Syntax: CKEDITOR.instances.textarea_id.getData();getData(); Where CKEDITOR.instances   :  gives all the instances of CKEDITOR; textarea_id   : it is ID of textarea that is containing data ; getData()       : return content of Ckeditor current instance. FCKEDITOR: To get content of Fckeditor we will create Instance of Fckeditor for textarea and then we will get data using GetHTML method. Syntax : FCKeditorAPI.GetInstance('textarea_id'). GetHTML(); Where textarea_id     :  it is ID of textarea that is containing data ; GetHTML()             :  This function returns content of textarea with id textarea_id.  

How to Detecting Leap Year using SQL Server 2012

CREATE FUNCTION dbo.IsLeapYear (@year INT) RETURNS INT AS BEGIN RETURN(IIF(DATEPART(dd,(EOMONTH(CONCAT(@year,'0201')))) = 29,1,0)) END ====================== How to Use ========================= SELECT dbo.IsLeapYear('2011') 'IsLeapYear'; SELECT dbo.IsLeapYear('2012') 'IsLeapYear';

How to remove NewLine characters from the data in SQL Server

select REPLACE(REPLACE(REPLACE(MyField, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')  from table

How to convert the Number to text string Using C#

 public string NumberToText(int number)     {         if (number == 0) return "Zero";         int[] num = new int[4];         int first = 0;         int u, h, t;         System.Text.StringBuilder sb = new System.Text.StringBuilder();         if (number < 0)         {             sb.Append("Minus ");             number = -number;         }         string[] words0 = { "", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine " };         string[] words1 = { "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " };         string[] words2 = { "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ",...

How to get Financial Year start date from Date in SQL Server

Create FUNCTION [dbo].[FinencialYearStartDate] (@Date DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @RetVal varchar(10) Declare @Month int Declare @Year int Select @Month=Month(@Date) Select @Year=Year(@Date) -- Assuming that the financial year is starting from april  if @Month>3  Begin    --Set @RetVal=cast(@Year As varchar(10))+'-'+cast(right('0' + rtrim(@Year+1),2) as varchar(2))    Set @RetVal='04/01/'+cast(@Year As varchar(10))   End  Else   Begin     --Set @RetVal=cast(@Year-1 as varchar(10))+'-'+cast(right('0' + rtrim(@Year),2) as varchar(2)); Set @RetVal='04/01/'+cast(@Year-1 As varchar(10))   End  Return @RetVal End ================================================ select dbo. FinencialYearStartDate ('02/02/2013') ==================Our Put====================== 04/01/2012

How to get Financial Year from Date IN SQL Server

CREATE FUNCTION [dbo].[FinencialYear] (@Date DATETIME) RETURNS VARCHAR(7) AS BEGIN DECLARE @RetVal varchar(7) Declare @Month int Declare @Year int Select @Month=Month(@Date) Select @Year=Year(@Date) -- Assuming that the financial year is starting from april if @Month>3  Begin Set @RetVal=cast(@Year As varchar(10))+'-'+cast(right('0' + rtrim(@Year+1),2) as varchar(2)) End Else Begin Set @RetVal=cast(@Year-1 as varchar(10))+'-'+cast(right('0' + rtrim(@Year),2) as varchar(2)); End Return @RetVal End ================================================ select dbo.FinencialYear('02/02/2013') ==================Our Put====================== 2012-13