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

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