Skip to main content

Ajax examples in asp.net

Customize Ajax Editor Control

 using System;using System.Data;  
 using System.Configuration;  
 using System.Linq;using System.Web;  
 using System.Web.Security;  
 using System.Web.UI;  
 using System.Web.UI.HtmlControls;  
 using System.Web.UI.WebControls;  
 using System.Web.UI.WebControls.WebParts;  
 using System.Xml.Linq;using AjaxControlToolkit.HTMLEditor;  
 /// /// Summary description for customEditor  
 /// /// namespace myControls  
 { public class customEditor : Editor  
 { public customEditor()  
 { // // TODO: Add constructor logic here // }  
 protected override void FillTopToolbar()  
 { TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Bold()); TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Italic()); TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Copy());  
 TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Cut());  
 TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.BulletedList()); TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.FixedBackColor()); TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.FontSize());  
 } protected override void FillBottomToolbar()  
 { BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.DesignMode()); BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.PreviewMode());  
 }  
 }}  
 Ajax and jason Enabled customized Grid  
 using System;  
 using System.Collections;  
 using System.Configuration;  
 using System.Data;  
 using System.Linq;  
 using System.Web;  
 using System.Web.Security;  
 using System.Web.UI;  
 using System.Web.UI.HtmlControls;  
 using System.Web.UI.WebControls;  
 using System.Web.UI.WebControls.WebParts;  
 using System.Xml.Linq;  
 using System.Text;  
 using System.IO;  
 using System.Runtime.Serialization;  
 public partial class AjaxSupport : System.Web.UI.Page  
 {  
 protected void Page_Load(object sender, EventArgs e)  
 {  
 // create sample datatable  
 DataTable dtJSON = new DataTable();  
 // add test columns to table  
 dtJSON.Columns.Add("index");  
 dtJSON.Columns.Add("itemcode");  
 dtJSON.Columns.Add("price");  
 // generate random data and add 10 records in temp table  
 Random randomNo = new Random();  
 int pagesize = 10;  
 int pagenum = 1;  
 if (Request.QueryString.Count > 0)  
 {  
 if (Request.QueryString["psize"] != null)  
 {  
 pagesize = Convert.ToInt32(Request.QueryString["psize"]);  
 }  
 if (Request.QueryString["pnumber"] != null)  
 {  
 pagenum = Convert.ToInt32(Request.QueryString["pnumber"]);  
 }  
 }  
 for (int i = 0; i < pagesize; i++) { dtJSON.Rows.Add(i, generateRandomString(5) + "-" + generateRandomString(5), randomNo.Next(99, 500)); }  
 // GetJson(dtJSON);  
  // generate JSON string out of the temp datatable and write it in response of the page  
 // string tmpstr = "{\"r1\":[{\"index\":\"0\",\"itemcode\":\"65fbc-88572\",\"price\":\"182\"},{\"index\":\"1\",\"itemcode\":\"34a50-50083\",\"price\":\"398\"},{\"index\":\"2\",\"itemcode\":\"30a8e-b2f65\",\"price\":\"365\"},{\"index\":\"3\",\"itemcode\":\"00785-7793e\",\"price\":\"290\"},{\"index\":\"4\",\"itemcode\":\"18303-8abd7\",\"price\":\"335\"},{\"index\":\"5\",\"itemcode\":\"fd5e3-4b5e2\",\"price\":\"422\"},{\"index\":\"6\",\"itemcode\":\"c0eb4-2f681\",\"price\":\"369\"},{\"index\":\"7\",\"itemcode\":\"15f08-584e4\",\"price\":\"394\"},{\"index\":\"8\",\"itemcode\":\"e6a2b-3eea4\",\"price\":\"315\"},{\"index\":\"9\",\"itemcode\":\"1134b-1f972\",\"price\":\"253\"}],\"r2\":[{\"PageSize\":\"10\",\"PageNumber\":\"1\",\"TotalRecord\":\"100\"}]}";  
 // Response.Write(tmpstr);  
 Response.Write(GetJson(dtJSON, pagesize, pagenum));  
  Response.Expires = -1;  
  }  
  public String GetJson(DataTable dt, int PageSize, int PageNumber)  
 {  
  string response = "";  
  try  
 { string datarow = "";  
 if (dt.Rows.Count > 0 && dt.Columns.Count > 0)  
 {  
 for (int row = 0; row < dt.Rows.Count; row++)  
 {  
 datarow += "{";  
  string tmp = "";  
  for (int col = 0; col < dt.Columns.Count; col++)  
 {  
  if (dt.Columns.Count - 1 != col)  
 { \  
 datarow += "\"" + dt.Columns[col].ToString() + "\" :" + "\"" + dt.Rows[row][col].ToString() + "\",";  
  }  
 else  
  {  
  datarow += "\"" + dt.Columns[col].ToString() + "\":" + "\"" + dt.Rows[row][col].ToString() + "\"";  
  }  
 }  
 if (dt.Rows.Count - 1 != row)  
 {  
 datarow += "},";  
 }  
  else  
  {  
  datarow += "}";  
  }  
 } \  
 int mod = (dt.Rows.Count % PageNumber);  
 int totalpages = 0;  
  if (mod > 0)  
 {  
 totalpages = (dt.Rows.Count / PageNumber) + 1;  
 }  
 else  
 {  
 totalpages = (dt.Rows.Count / PageSize);  
 }  
 datarow = "{\"r1\" :[" + datarow + "],\"r2\":[{\"PageSize\":\"" + PageSize + "\",\"PageNumber\":\"" + PageNumber + "\",\"TotalRecord\":\"" + dt.Rows.Count + "\",\"TotalPages\":\"" + totalpages + "\"}]}";  
 response = datarow;  
 }  
 }  
 catch (Exception e)  
 {  
 throw;  
 }  
 return response;  
 }  
 public static string GetJSONString(DataTable Dt)  
 {  
 string[] StrDc = new string[Dt.Columns.Count];  
 string HeadStr = string.Empty;  
 Dt.TableName = "DummyData";  
 for (int i = 0; i < Dt.Columns.Count; i++)  
 {  
  StrDc[i] = Dt.Columns[i].Caption;  
 HeadStr += "\"" + StrDc[i] + "\" : \"" + StrDc[i] + i.ToString() + "\",";  
  }  
 HeadStr = HeadStr.Substring(0, HeadStr.Length - 1);  
 StringBuilder Sb = new StringBuilder();  
 Sb.Append("{\"" + Dt.TableName + "\" : \"[");  
 for (int i = 0; i < Dt.Rows.Count; i++)  
 { string TempStr = HeadStr; Sb.Append("{");  
 for (int j = 0; j < Dt.Columns.Count; j++)  
 {  
 TempStr = TempStr.Replace(Dt.Columns[j] + j.ToString(), Dt.Rows[i][j].ToString());  
 }  
 Sb.Append(TempStr +  
 }  
  Sb = new StringBuilder(Sb.ToString().Substring(0, Sb.ToString().Length - 1));  
 Sb.Append("]\"};");  
  return Sb.ToString();  
  }  
 public static string generateRandomString(int length)  
 {  
 string randomString = Guid.NewGuid().ToString("N");  
 randomString = randomString.Substring(0, length);  
 return randomString;  
 }  
 'Using Populate On Demand and AJAX in Treeview  
 PopulateOnDemand="true" Text="Node 0" />  

Popular posts from this blog

All songs notation and chords at one place

Song : O Saathi Re Film : Mukhathar Ka Sikkandhar Uses : C D D# E G A Note : The numbers at the end of the lines indicate line numbers. Pallavi: O saathi re, tere binaa bhi kya jina, tere binaa bhi kya jina A- C D D#....,D D C DD E...C..CA-...,D D C DD E...CC.......1 Play line 1 again phulon men khaliyon men sapnom ki galiyon men GGG...GAGE.. GGG G A G E.................................................2 tere bina kuchh kahin naa E A G E D C D D#.......................................................................3 tere binaa bhi kya jina, tere binaa bhi kya jina D D C DD E....C..CA-..., D D C DDE....CC.............................4 Charanam: har dhadkan men, pyaas hai teri, sanson men teri khushboo hai CCC C D C A-, CCC C D C A-, DDD DED CD EE.. CCCC......................5 is dharthi se, us ambar tak, meri nazar men tu hi tu hai CCC C D C A-, CCC C D C A-, DDD DED CD EE.. CCCC......................6 pyaar yeh tute naa GGG... GAG D#......E............................

Song Aankhen Khuli Ho lyrics notation

Song : Aankhen Khuli Ho Movie: Mohabbatein Notes used : W=>Western - C D E F G- A- B-/ H=>Hindustani - S R G M P- D- N- ( Here for western, G=G-, A=A-, & B=B- ) ( For hindustani, P=P-, D=D-, & N=N- ) Song I : Aankhen Khuli...Ho Ya.. Ho Bandh W=> A.... C... B..C.. E.. E...... A... A.... H=> D... S... N..S.. G G....... D... D.... Deedaar Un Ka Ho.o.taa Hai.. W=> A...B....A....D.BAG....ADB... H=> D...N...D.....R.NDP...DRN... Kaise Kahoon Main O..Yaaraa W=> B..D.. D....E.... D.....C..C..C... H=> N..R.. R....G... R.....S..S..S..... Ye Pyaar Kaise Hota Hai W=> E...B.....DB...AG...B..AA H=> G...N....RN...DP...N...DD (Tururu ru ru, ru ru rururu ru......) W=> AA...GA...BCE..., B...DB..GA H=> DD...PD...NSG..., N..RN.. PD Song II: Aa.aj He Kisi..par Yaa.ro.on..., Marke De..Khe..gein Hum W=> E....FEDCBABC.D.. D D......., G A B C.... E.......D...D..... H=> G....MGRSNDNS.R. R R......., P D N S.....G........R...R.... Pyaar Ho...

How to create View using Union query from one database to another database in SQL

To create View using Union query from one database to another database in SQL you can get hints from below example its very simple your column should be the same type and number of the column should be same to create union query view. USE [TestDB] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create VIEW [dbo].[Test_FinancialDimension] AS ( SELECT [key_] ,[NAME] ,[Value] FROM MicrosoftDynamicsAX.dbo.dimattributecompanyinfo union SELECT [key_] ,[NAME] ,[Value] FROM MicrosoftDynamicsAX.dbo.DimAttributeOMCostCenter --union -- SELECT [key_] ,[NAME],[Value] FROM MicrosoftDynamicsAX.dbo.DimAttributeHcmWorker union SELECT [key_] ,[NAME] ,[Value] FROM MicrosoftDynamicsAX.dbo.DIMATTRIBUTEOMDEPARTMENT union SELECT [key_] ,[NAME] ,[Value] FROM MicrosoftDynamicsAX.dbo.DimAttributeOMB...