C# .net单击图像按钮在Internet Explorer中不起作用,但在Firefox中起作用
我已经为ascx编写了C#代码。我试图通过点击图片按钮发送一封电子邮件,该按钮在Mozilla Firefox中有效,但在Internet Explorer中无效 单击按钮时调用此函数:C# .net单击图像按钮在Internet Explorer中不起作用,但在Firefox中起作用,c#,asp.net,C#,Asp.net,我已经为ascx编写了C#代码。我试图通过点击图片按钮发送一封电子邮件,该按钮在Mozilla Firefox中有效,但在Internet Explorer中无效 单击按钮时调用此函数: <%@ Control Language="C#" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Web.UI.WebControls" %> <%@ Import Namespace=
<%@ 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>
受保护的void btnsupmit\u单击(对象发送者,事件参数e)
{
如果(第页有效)
{
来自manoj的字符串。singh@espireinfo.com";
字符串到manoj。singh@espireinfo.com";
string subject=“保持我的更新”;
字符串sendguide=“”;
if(optsendguide.Checked)
{
sendguide=“是,请发送给我”;
}
其他的
{
sendguide=“不,请不要给我发邮件”;
}
//建立正文
字符串体=”;
body+=String.Format(“Title:{0}”,Title.Text);
body+=String.Format(“名字:{0}”,名字.Value);
body+=String.Format(“Sur Name:{0}”,姓氏.Value);
body+=String.Format(“电子邮件地址:{0}”,Email.Value);
body+=String.Format(“breaktype:{0}”,breakTypeDescription.Text);
body+=String.Format(“大周末指南:{0}”,sendguide);
正文+=”;
字符串错误=Utilities.sendmail(收件人、发件人、主题、正文);
如果(错误==“”)//成功
{
重定向(“index.aspx”);
}
else//错误
{
响应。写入(错误);
}
}
}
标记:
<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>
在代码隐藏中只需更改 受保护的void btnsupmit\u单击(对象发送者,事件参数e) 与
受保护的无效btnSubmit\u单击(对象发送者,ImageClickEventArgs e)为什么要使用ImageButton。。。为什么不使用一个普通的按钮,用CSS改变背景呢 hai all 这段代码是在IE中工作的,不是mozilla,有人知道吗 document.onkeypress=KeyCheck; 功能键检查(e){
var-KeyID=(window.event)?event.keyCode:e.keyCode;
if(KeyID==0){
var image=document.getElementById(“”);
var label=document.getElementById(“”);
如果(图像!=null){
document.getElementById(“”.style.display=“block”;
初始化对象();
}
否则{
document.getElementById(“”.style.display=“block”;
初始化对象();
}
}
否则如果(KeyID!=0){
如果(图像!=null){
document.getElementById(“”.style.display=“block”;
}
否则{
document.getElementById(“”.style.display=“block”;
}
}
}
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";
}
}
}