asp.net中程序用到了母版页,在母版页中的按钮要点击2次才执行单击事件,请问是什么原因??如何解决!!!

解决方案 »

  1.   

    找到原因了!把按钮设置成不激发验证了即:CausesValidation="False"
    为什么不激发验证要点击2次才生效啊?有什么办法可以解决!
      

  2.   

    终于找到问题原因了!因为母版页里用到了ewebeditor编辑器,所以按钮都需要点2次才起作用。
    <iframe src='WebEditor/ewebeditor.htm?id=ctl00$ContentPlaceHolder1$txtContent' frameborder='0' scrolling='no' style="height: 278px; width: 90%;"></iframe>这个是母版页里引用编辑器的代码,把这个代码去掉,按钮点击1次就生效!!!
    请问什么原因,高手解答!!应如何处理??
      

  3.   

    http://hi.baidu.com/baiping588/blog/item/f819c0ae5120b9eefbed5006.html
    这个是你想要的吗
      

  4.   

    我的不是ewebeditor编辑器上的按钮不效,而是界面里的button1按钮第1次点击无效,第2次点击又好用的问题!!!
      

  5.   

    ASP.NET  机制问题
    ,你用的是framework2.0?
      

  6.   

    你哪个控件 使用了 Autopostback 了?
      

  7.   

    用的是framework2.0,现在跟Autopostback没有关系,就是同一个母版页下,如果即包括了ewebeditor编辑器,又包括button1按钮等,则button1按钮点击第1次没有反映,第2次才执行事件!
      

  8.   


    iframe是框架,貌似不是母板,麻烦请具体的代码贴出来让大家看看...
      

  9.   

    以下是母版页内容
    <%@ Page Language="C#" MasterPageFile="~/Admin/Main.master" AutoEventWireup="true" CodeFile="GoodsAdd.aspx.cs" Inherits="GoodsAdd" Title="商品添加" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <table border="0" cellpadding="0" cellspacing="0" style="background-image: url(image/log/main.jpg);
            width: 100%; height: 328px" >
            <tr>
                <td style="width:10%; border-right: #cccccc 1px dotted;" rowspan="5" valign="top" align="center">
                    <div style="text-align: center">
                        &nbsp;</div>
                    </td>
                <td style="width: 20%" align="right">
                    商品分类:</td>
                <td align="left"  style="width:70%">
                    <asp:DropDownList ID="DropDownList1" runat="server" Width="106px">
                    </asp:DropDownList></td>
                <td align="left" rowspan="4" style="width: 70%">
                        <table style="width: 243px">
                            <tr>
                                <td align="left">
                    <asp:Image ID="Image1" runat="server" BorderStyle="Outset" Height="122px" Width="112px" /></td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:FileUpload ID="FileUpload1" runat="server" Width="187px" />
                    <asp:Button ID="Button1" runat="server" Text="预览" OnClick="Button1_Click" CausesValidation="False" /></td>
                            </tr>
                        </table>
                </td>
            </tr>
            <tr>
                <td align="right">
                    商品名称:</td>
                <td style="" align="left">
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="TextBox1"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style=" height: 24px;" align="right">
                    销售价格:</td>
                <td style=" height: 24px;" align="left">
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
                        ErrorMessage="*"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="" align="right">
                    库存:</td>
                <td style="" align="left">
                    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox3"
                        ErrorMessage="*"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td align="right">
                    详细介绍:</td>
                <td align="left" colspan="2">
                <asp:TextBox ID="txtContent" runat="server" style="display:none;"></asp:TextBox>
            <iframe src='../WebEditor/ewebeditor.htm?id=ctl00$ContentPlaceHolder1$txtContent' frameborder='0' scrolling='no' style="height: 278px; width: 99%;"></iframe>
                </td>
            </tr>
            <tr>
                <td style="width: 100px">
                </td>
                <td style="width: 100px">
                </td>
                <td>
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/image/log/add_1.jpg"
                        OnClick="ImageButton1_Click" />&nbsp;<asp:ImageButton ID="ImageButton2" runat="server"
                            ImageUrl="~/image/log/Cancel_1.jpg" OnClick="ImageButton2_Click" /></td>
                <td>
                </td>
            </tr>
        </table>
    </asp:Content>
    因为有了红色字体部分的编辑框,所以,上面所有的button按钮,都必须点2次才起作用!!!
    请指教!!!
      

  10.   

    用了编辑器后,就不能再用验证控件了。
    编辑器实际上是模仿了一个多行文本框。如果你用了验证控件,那么第一次点击按钮,验证控件就会报错,它会认为你的文本框为空,没有内容。实际上你的内容在模仿的文本框里面。
    解决此问题的办法就是不要用验证控件,可以用js或jquery进行验证。