2008-11-18 65 views
0

我已經編寫了ascx的C#代碼。我正在嘗試發送一封電子郵件,其中的圖片按鈕在Mozilla Firefox中工作,但不在Internet Explorer中。.net點擊圖像按鈕不工作在Internet Explorer中,但在Firefox中

這個函數被調用按鈕點擊:

<%@ 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 = "[email protected]"; 
      string to = "[email protected]"; 
      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> 

標記:

<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

海所有,

此代碼在IE工作不是Mozilla的,任何人給理念

document.onkeypress =鍵校驗; 功能KeyCheck(e){

 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"; 
      } 

     } 
    } 
1

在後面的代碼只是改變 保護無效btnSubmit_Click(對象發件人,EventArgs的)

與 protected void btnSubmit_Click(object sender,ImageClickEventArgs e)

0

爲什麼使用ImageButton ...爲什麼不使用常規按鈕,並使用CSS更改背景。

相關問題