Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net call back event is not working in IE 11

Posted on 2013-12-19
1
Medium Priority
?
1,780 Views
Last Modified: 2014-01-02
I have IE 11 and I am trying to run this code
but It is not calling the server method and getting its result.

I run it in Compatibility mode and it worked, it also worked in chrome and firefox.

Not sure why it is not working in IE 11.

HERE IS MY CODE
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ICALLBACK.WebForm1" %>

<!DOCTYPE html>

<html >
<head runat="server">
    <title></title>
      <script type="text/ecmascript">
          function LookUpStock() {
              var lb = document.getElementById("ListBox1");
              var product = lb.options[lb.selectedIndex].text;
              alert('1');
              CallServer(product, "");
          }

          function ReceiveServerData(rValue) {             
              document.getElementById("ResultsSpan").innerHTML = rValue;

          }
  </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:ListBox ID="ListBox1" Runat="server"></asp:ListBox>
      <br />
      <br />
      <button type="Button" onclick="LookUpStock()">Look Up Stock</button>
      <br />
      <br />
      Items in stock: <span id="ResultsSpan" runat="server"></span>
      <br />
    </div>
    </form>
</body>
</html>

Open in new window



CS. FILE CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ICALLBACK
{
    public partial class WebForm1 : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
    {
        protected System.Collections.Specialized.ListDictionary catalog;
        protected String returnValue;

        protected void Page_Load(object sender, EventArgs e)
        {
            String cbReference =
            Page.ClientScript.GetCallbackEventReference(this,
            "arg", "ReceiveServerData", "context");
            String callbackScript;
            callbackScript = "function CallServer(arg, context)" +
                "{ " + cbReference + ";}";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
                "CallServer", callbackScript, true);

            catalog = new System.Collections.Specialized.ListDictionary();
            catalog.Add("monitor", 12);
            catalog.Add("laptop", 10);
            catalog.Add("keyboard", 23);
            catalog.Add("mouse", 17);

            ListBox1.DataSource = catalog;
            ListBox1.DataTextField = "key";
            ListBox1.DataBind();
        }

        public string GetCallbackResult()
        {
            return returnValue;
        }

        public void RaiseCallbackEvent(string eventArgument)
        {
            if (catalog[eventArgument] == null)
            {
                returnValue = "-1";
            }
            else
            {
                returnValue = catalog[eventArgument].ToString();
            }
        }
    }
}

Open in new window

0
Comment
Question by:yadavdep
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
Stephan earned 1060 total points
ID: 39731505
Do you receive an javascript error when clicking the button?

There is a known issue regarding the new IE browser version:
http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question