Page_load事件仅在Firefox 3.6.6上执行两次(在IE和crome上正常工作) [英] Page_load event executing twice only on Firefox 3.6.6(working fine with IE and crome)

查看:80
本文介绍了Page_load事件仅在Firefox 3.6.6上执行两次(在IE和crome上正常工作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我真的不知道为什么我的page_load事件执行两次...

注册我的网站时,我已经放置了验证码图片

我正在调用JpegImage.aspx页面以加载图像的注册代码.

Hi guys,

I have really no clue why my page_load event executing twice...

I have placed captcha Image while registration of my WEBSITE

Registration code where I am calling JpegImage.aspx page to load the Image.

<asp:WizardStep Title="CAPTCHA" ID="wsCaptcha" runat="server">
                        <div class="divContainerBox">
                            <div class="divContainerRow">
                                
                                
                                    <div class="divContainerCell">
                                        <b><asp:Image runat="server" ImageUrl="../Images/CaptchaImage/JpegImage.aspx"></asp:Image></b>
                                    </div>
                                
                                <div class="divContainerRow">
                                    <div class="divContainerTitle">
                                        Please copy what you see in the image above into the box below.
                                    </div>
                                </div>
                                <div class="divContainerRow">
                                    <div class="divContainerCell">
                                        <asp:TextBox ID="txtCaptcha" runat="server"></asp:TextBox>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </asp:WizardStep>


这是JpegImage.aspx的html代码:


This is the JpegImage.aspx''s html code:

<%@ Page language="c#" CodeFile="JpegImage.aspx.cs" AutoEventWireup="false" Inherits="jayee.DatingWeb.Images.CaptchaImage.JpegImage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
	<head>
		<title>JpegImage</title>
		<meta name="GENERATOR" content="microsoft visual studio 7.0"/>
		<meta name="CODE_LANGUAGE" content="c#"/>
		<meta name="vs_defaultClientScript" content="JavaScript"/>
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"/>
	</head>
	<body>
		<form id="_JpegImage" method="post" runat="server">
		</form>
	</body>
</html>


问题在于jpegImage.cs的以下page_load事件:


The problem is with this page_load event of jpegImage.cs:

public partial class JpegImage : Page
    {
        private readonly Random _random = new Random();
        private IWebContext _webContext;
        private void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack != true)
            {
                _webContext = ObjectFactory.GetInstance<IWebContext>();
                _webContext.CaptchaImageText = GenerateRandomCode();
                var ci = ObjectFactory.GetInstance<ICaptcha>();
                ci.Text = _webContext.CaptchaImageText;
                ci.Width = 200;
                ci.Height = 50;
                ci.FamilyName = "Century Schoobook";
                Response.Clear();
                Response.ContentType = "image/jpeg";
                ci.Image.Save(Response.OutputStream, ImageFormat.Jpeg);
                ci.Dispose();
            }
        }
        private string GenerateRandomCode()
        {
            string s = "";
            for (int i = 0; i < 6; i++)
                s = String.Concat(s, _random.Next(10).ToString());
            return s;
        }
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }
        private void InitializeComponent()
        {
            Load += Page_Load;
        }


谁能帮我解决我做错的地方,为什么仅Firefox会给我带来麻烦.我观察到没有其他page_load事件运行两次.


Can anyone please help where I was doing wrong why Firefox alone giving me trouble. I have observed no other page_load events are running twice.

推荐答案

队友,这只是一个建议,添加 ALT 属性到图片标签和再试一次,然后告诉我们.
Hey mate, this is only a suggestion, add the ALT attribute to the Image Tag & try again then tell us.


感谢您的回复

您是要向ASP Image标签添加Alternate Text属性吗?
我想是的,我做到了.还是一样.

顺便说一句,我收到一个警告,说我在向导步骤中使用了
ImageUrl为

< asp:Image runat =服务器" ImageUrl ="../Images/CaptchaImage/JpegImage.aspx"></asp:Image>

但是Resharper(Visual Studio伴侣)建议我,图片网址必须是图片而非文件.
Thanks for the reply

Did you mean to add Alternate Text attribute to ASP Image tag?
I think so and I did that. Still the same.

By the way I am getting one warning that in the wizard step I have used
ImageUrl as

<asp:Image runat="server" ImageUrl="../Images/CaptchaImage/JpegImage.aspx"></asp:Image>

but Resharper(visual studio companion) advising me that image url must be a Image not File.


这篇关于Page_load事件仅在Firefox 3.6.6上执行两次(在IE和crome上正常工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆