Note that there are some explanatory texts on larger screens.

plurals
  1. POAsync Javascript callback not triggering the RaiseCallBackEvent function
    primarykey
    data
    text
    <p>In my asp.net application I used the async javascript callback. The requirement is once the user enters the Postal code an async javascript callback function should be called. And the server side code must return me the <strong>city</strong> with respect to the <strong>postal code</strong>.</p> <p>The coding I did is:</p> <pre><code>&lt;asp:TextBox ID="txtPostCode" runat="server" CssClass="textbox" onchange="javascript: getCityAndStreet();" BorderStyle="Ridge" Height="20px" style="margin-left: 10px" Width="442px"&gt;&lt;/asp:TextBox&gt; </code></pre> <p>This textbox <code>onchange</code> it will call the javascript <code>function getCityAndStreet()</code></p> <pre><code>function getCityAndStreet() { var postalCode = document.getElementById('&lt;%=txtPostCode.ClientID%&gt;'); CallServer(postalCode.value, ""); } function ReceiveCityAndStreet(rValue,context) { alert(rValue); var city = document.getElementById('&lt;%= txtCity.ClientID%&gt;'); city.value = rValue; } </code></pre> <p>Here the <strong>CallServer</strong> is the server side runtime javascript which is registered as below</p> <pre><code>protected void Page_Init(object sender, EventArgs e) { String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveCityAndStreet", "context",true); String callbackScript; callbackScript = "function CallServer(arg, context)" + "{ " + "alert('Entered inside CallServer' + arg);" + cbReference + ";}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true); } </code></pre> <p>I implemented the <code>ICallBackHandler</code> and by this I got 2 methods:</p> <pre><code>string ICallbackEventHandler.GetCallbackResult() { return cityAndStreet; } void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument) { txtStreet.Enabled = true; txtCity.Enabled = true; cityAndStreet = eventArgument; } </code></pre> <p>in page_load function I just disabled the <code>txtStreet.Enabled</code>. <code>txtCity.Enabled</code> text boxes and on the raise callbackevent I am enabling it.</p> <p>The issue here is the <code>RaiseCallBackEvent</code> is not working. I mean its not been triggered implicitly.</p> <p>(This application is not accessed directly in the browser it is accessed through the SharePoint site)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload