.net click on an image button not working in Internet Explorer but Firefox

I have written C # code for ascx. I am trying to send an email on an image button click, which works in Mozilla Firefox but not Internet Explorer.

This function is called by clicking a button:

<%@ Control Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Globalization" %>

<script language="c#" runat="server">
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string from = "manoj.singh@espireinfo.com";
            string to = "manoj.singh@espireinfo.com";
            string subject = "Keep me Updated";
            string sendguide = "";

            if (optsendguide.Checked)
            {
                sendguide = "Yes Please send me";

            }
            else
            {
                sendguide = "No Please don't send me";
            }

            // build up the body text
            string body = "<html><body>";
            body += String.Format("<div>Title: {0} </div>", title.Text);
            body += String.Format("<div>First Name: {0} </div>",firstname.Value);
            body += String.Format("<div>Sur Name: {0} </div>", surname.Value);
            body += String.Format("<div>Email address: {0} </div>", email.Value);
            body += String.Format("<div>Break Type: {0} </div>", breakTypeDescription.Text);
            body += String.Format("<div>Big weekends guide: {0} </div>", sendguide);
            body += "</body></html>";

            string error = Utilities.SendEmail(to, from, subject, body);
            if (error == "") // success
            {
                Response.Redirect("index.aspx");
            }
            else // error
            {
                Response.Write(error);
            }
        }
    }
</script>

      

Markup:

<div class="form_elm_button">
    <asp:ImageButton ID="SubmitButton"
                     runat="server"
                     Text="Submit"
                     ImageUrl="/images/17-6164button_submit.png"
                     OnClick="btnSubmit_Click"
                     CausesValidation="true"/>
</div>

      

0


source to share


3 answers


hai all,

This code works in IE not mozilla, someone give an idea



document.onkeypress = KeyCheck; KeyCheck (e) function {

        var KeyID = (window.event) ? event.keyCode : e.keyCode;
        if (KeyID == 0) {
            var image = document.getElementById("<%= imagetirukural.ClientID%>");
            var label = document.getElementById("<%= lbltirukural.ClientID%>");
            if (image != null) {

                document.getElementById("<%= imagetirukural.ClientID%>").style.display = "block";
                InitializeTimer();
            }
            else {
                document.getElementById("<%= lbltirukural.ClientID%>").style.display = "block";
                InitializeTimer();
            }
        }
        else if (KeyID != 0) {


            if (image != null) {
                document.getElementById("<%= imagetirukural.ClientID%>").style.display = "block";
            }
            else {
                document.getElementById("<%= lbltirukural.ClientID%>").style.display = "block";
            }

        }
    }

      

0


source


The code has just changed protected void btnSubmit_Click (object sender, EventArgs e)



with protected void btnSubmit_Click (object sender, ImageClickEventArgs e)

+1


source


Why are you using ImageButton ... why not just use a regular button and change the background with CSS.

0


source







All Articles