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

Resolved : Power BI Report connection error during execution

Getting Below Power BI Report connection error during execution . Error: Something went wrong Unable to connect to the data source undefined. Please try again later or contact support. If you contact support, please provide these details. Underlying error code: -2147467259 Table: Business Sector. Underlying error message: AnalysisServices: A connection cannot be made. Ensure that the server is running. DM_ErrorDetailNameCode_UnderlyingHResult: -2147467259 Microsoft.Data.Mashup.ValueError.DataSourceKind: AnalysisServices Microsoft.Data.Mashup.ValueError.DataSourcePath: 10.10.10.60;T_CustomerMaster_ST Microsoft.Data.Mashup.ValueError.Reason: DataSource.Error Cluster URI: WABI-WEST-EUROPE-redirect.analysis.windows.net Activity ID: c72c4f12-8c27-475f-b576-a539dd81826a Request ID: dfb54166-c78f-4b40-779f-e8922a6687ad Time: 2019-09-26 10:03:29Z Solution: We found report connection not able to connect to SQL Analysis service so tried below option. Re

Song- Khamoshiyan Piano keyboard Chord,Notation and songs Lyrics

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