Posts

Showing posts with the label C#

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 ...

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 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 ",...

ASP.NET Charting Control

Image
Microsoft recently released a cool new ASP.NET server control - <asp:chart /> - that can be used for free with ASP.NET 3.5 to enable rich browser-based charting scenarios: Download the free Microsoft Chart Controls Download the VS 2008 Tool Support for the Chart Controls Download the Microsoft Chart Controls Samples Download the Microsoft Chart Controls Documentation Visit the Microsoft Chart Control Forum Once installed the <asp:chart/> control shows up under the "Data" tab on the Toolbox, and can be easily declared on any ASP.NET page as a standard server control: <asp:chart /> supports a rich assortment of chart options - including pie, area, range, point, circular, accumulation, data distribution, ajax interactive, doughnut, and more.  You can statically declare chart data within the control declaration, or alternatively use data-binding to populate it dynamically.  At runtime the server control generates an image (for ...

Save and Retrieve Images from the Database using ASP.NET 2.0 and ASP.NET 3.5

Database Script CREATE DATABASE [Employee] GO USE [Employee] GO CREATE TABLE EmpDetails ( empid int IDENTITY NOT NULL, empname varchar ( 20 ), empimg image ) Step 1: Create a new asp.net website. In the code-behind, add the following namespace C# using System.Data.SqlClient; VB.NET Imports System.Data.SqlClient Step 2: Drag and drop two label and one textbox control. Also drag drop a FileUpload control and a button control to upload the selected image on button click. As mentioned earlier, there are no validations performed. The source would look similar to the following: < html xmlns ="http://www.w3.org/1999/xhtml"> < head runat ="server">     < title > Save Retrieve Images </ title > </ head > < body >     < form id ="form1" runat ="server">     < div >             < as...