Read without ads and support Scribd by becoming a Scribd Premium Reader.
 
ICallbackEventHandler//THIS BELOW CODE REPRESENT THE USING OF I CALLBACK WHERE PAGE DOENT REFRESHWHEN REQUEST IS PLACED HERE GOES WITH C# CODEusingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Collections.Generic;usingSystem.Data.SqlClient;usingSystem;public partial class Test_Callback: System.Web.UI.Page,ICallbackEventHandler { private stringm_callbackResult =String.Empty;  protected voidPage_Load(objectsender,EventArgse) {Label1.Text =DateTime.Now.ToString(); if(!Page.IsPostBack){ this.lblQuote.Text =this.getQuote(); } // Creating the scripts which need to be called // this below statment is based with timer for each second //string clientScript = "function serverRequest(args, context){{ " +ClientScript.GetCallbackEventReference(this, "args", "getResult", "context")+ "; }} function getResult(result, context){{ eval(result); callServer(); }}function callServer(){setTimeout('serverRequest();', 1000);} callServer();"; // this below statment is based with out timerstringclientScript ="function serverRequest(args, context){{ "+ ClientScript.GetCallbackEventReference(this,"args","getResult","context") +"; }} function getResult(result, context){{ eval(result); callServer(); }}function callServer(){serverRequest()} callServer();"; // Register the client script ScriptManager.RegisterClientScriptBlock(this,typeof(Page), "RandomQuoteCallback", clientScript,true); } private stringgetQuote() { intrandomIndex = (new Random()).Next(0, 29);  stringWav =string.Empty;  SqlConnectioncon =new SqlConnection("server=softpro- srv\\sqlexpress;User Id=apdrptest;Password=Apdrp@test;database=APDRP;"); SqlDataAdapterda =new SqlDataAdapter("select Parm_name from Parameters where Parm_Id="+ randomIndex +"", con);  DataSetds =new DataSet(); da.Fill(ds);returnWav = ds.Tables[0].Rows[0].ItemArray[0].ToString(); //int randomIndex = (new Random()).Next(0, m_quotes.Count);
 
 //return m_quotes[randomIndex].Author + " - " +m_quotes[randomIndex].QuoteMessage;} //public string getsample() //{ // SqlConnection con = new SqlConnection("server=softpro-srv\\sqlexpress;User Id=apdrptest;Password=Apdrp@test;database=APDRP;"); // SqlCommand cmd = new SqlCommand("insert into " //}#regionICallbackEventHandler Members /// <summary>  ///This method returns the result of a callback /// </summary>  /// <returns>a string of the result of the callback</returns>  public stringGetCallbackResult() { returnm_callbackResult;} /// <summary>  ///This method processes the callback event /// </summary>  /// <param name="eventArgument"></param>  public voidRaiseCallbackEvent(stringeventArgument) {m_callbackResult ="document.getElementById('randomQuote').innerHTML= '"+this.getQuote() +"'"; }#endregion}Callback.aspx<asp:Content ID="Content1" ContentPlaceHolderID="CPHead" runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="CP1" runat="Server">  <asp:Label ID="lblQuote" runat="server" Text="Label"></asp:Label>  <div id="randomQuote">  <asp:Literal runat="Server" ID="Literal1" /> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="CP2" runat="Server">  <asp:Label ID="Label1" runat="server" Width="120px" Height="20px" BorderColor="Aqua"></asp:Label> </asp:Content> =======================******************==================================
Icallback Using in GridCiew .C#
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;
 
usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Data.SqlClient;usingSystem.IO;public partial class callbackgrid: System.Web.UI.Page,ICallbackEventHandler { private stringstrOutput;  protected voidPage_Load(objectsender,EventArgse) { if(!IsPostBack){ ClientScriptManagercsm = Page.ClientScript; StringcallbackRef = csm.GetCallbackEventReference(this,"arg", "fnGetOutputFromServer","");  StringcallbackScript ="function fnCallServerMethod(arg,context) {"+ callbackRef +"; }"; csm.RegisterClientScriptBlock(this.GetType(),"fnCallServerMethod", callbackScript,true); GridView1.DataSource = BindGrid();GridView1.DataBind();}} private DataTableBindGrid() { stringsql ="Select * from LoadSurvey";  SqlDataAdapterda =new SqlDataAdapter(sql,"server=softpro- srv\\sqlexpress;User Id=apdrptest;Password=Apdrp@test;database=APDRP;"); DataTabledt =new DataTable(); da.Fill(dt); this.ViewState["Table"] = dt;  returndt;} public voidRaiseCallbackEvent(StringclientArgs) { string[] str = clientArgs.Split('|'); FilterGrid(str[0], str[1]);} public stringGetCallbackResult() { returnstrOutput;} private voidFilterGrid(stringCusName,stringCusCity)
Search History:
Searching...
Result 00 of 00
00 results for result for
  • p.
  • Notes
    Load more