为什么我在aspx源页面中插入了scriptmanager,updatepanel和内容模板后,为什么我的按钮事件和gridview编辑事件没有触发 [英] why my button events and gridview edit events are not firing after i have inserted scriptmanager,updatepanel and content template in my aspx source page

查看:57
本文介绍了为什么我在aspx源页面中插入了scriptmanager,updatepanel和内容模板后,为什么我的按钮事件和gridview编辑事件没有触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Language="C#" MasterPageFile="~/NewMaster.master"  AutoEventWireup="true" CodeFile="Assignment.aspx.cs" Inherits="Assignment" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" >





</asp:Content>





<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">







<script language="javascript" type="text/javascript">
    function ltrim(s) {
        return s.replace(/^\s*/, "");
    }

    function trim(s) {
        //s=s.replace(/^\s*/,"");
        return s.replace(/^\s+|\s+$/g, "");
    }


    function Ass() {
        var ay = document.getElementById('<%=DropDownList2.ClientID %>');
        var co = document.getElementById('<%=DropDownList3.ClientID %>');
        var yr = document.getElementById('<%=DropDownList4.ClientID %>');
        var sem = document.getElementById('<%=DropDownList5.ClientID %>');

        if (ay.selectedIndex == 0)
        { ay.style.background = 'Yellow'; alert("Please select the academic year !"); ay.focus(); return false; }
        else
        { ay.style.background = 'White'; }

        if (co.selectedIndex == 0)
        { co.style.background = 'Yellow'; alert("Please select the course !"); co.focus(); return false; }
        else
        { co.style.background = 'White'; }

        if (yr.selectedIndex == 0)
        { yr.style.background = 'Yellow'; alert("Please select the year !"); yr.focus(); return false; }
        else
        { yr.style.background = 'White'; }

        if (sem.selectedIndex == 0)
        { sem.style.background = 'Yellow'; alert("Please select the semester !"); sem.focus(); return false; }
        else
        { sem.style.background = 'White'; }
    }


</script>

<asp:ScriptManager ID="scriptmanager" runat="server"></asp:ScriptManager>



<asp:UpdatePanel ID="updatepanel1" runat="server">


<ContentTemplate>




    <div style="width: 100%;">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="95%" valign="top" bgcolor="#FFFFFF">
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">

                        <tr>

                            <td width="100%" valign="top">
                                <table width="100%" border="0" cellspacing="0" cellpadding="2" style="background-color: #ffffff">
                                    <tr>
                                        <td align="center">
                                            <img src="images/Head/assg.PNG" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" width="100%">
                                            <table width="42%" align="center">
                                                <tr>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label3" runat="server" CssClass="lbl" Text="Academic Year"></asp:Label>
                                                    </td>
                                                    <td align="left" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:DropDownList ID="DropDownList2" runat="server" Width="120px">
                                                        </asp:DropDownList>
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label4" runat="server" CssClass="lbl" Text="Course"></asp:Label>
                                                    </td>
                                                    <td align="left" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:DropDownList ID="DropDownList3" runat="server" Width="120px">
                                                        </asp:DropDownList>
                                                </tr>
                                                <tr>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label5" runat="server" CssClass="lbl" Text="Year"></asp:Label>
                                                    </td>
                                                    <td align="left" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:DropDownList ID="DropDownList4" runat="server" Width="120px">
                                                        </asp:DropDownList>
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:Label ID="Label6" runat="server" CssClass="lbl" Text="Semester"></asp:Label>
                                                    </td>
                                                    <td align="left" width="2%">
                                                        :
                                                    </td>
                                                    <td align="left" width="24%">
                                                        <asp:DropDownList ID="DropDownList5" runat="server" Width="120px">
                                                        </asp:DropDownList>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="center" width="100%" colspan="6">
                                                        <asp:Button ID="Button5" runat="server" CssClass="Fetch" OnClientClick="return Ass()"

                                                            OnClick="Button5_Click" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <br />
                                            <asp:GridView ID="GridView1" runat="server" DataKeyNames="ALID" AutoGenerateColumns="False"

                                                Width="100%" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" BorderStyle="None"

                                                BorderWidth="1px" CellPadding="3" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging"

                                                OnRowCommand="GridView1_RowCommand" OnRowEditing="GridView1_RowEditing" OnRowDeleting="GridView1_RowDeleting">
                                                <Columns>
                                                    <asp:TemplateField HeaderText="S.No">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblno" runat="server" Text='<%#Container.DataItemIndex+1 %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:BoundField HeaderText="S.No" Visible="false" DataField="ALID"></asp:BoundField>
                                                    <asp:BoundField DataField="ACYEAR" HeaderText="Academic Year"></asp:BoundField>
                                                    <asp:BoundField DataField="CNAME" HeaderText="Course Name"></asp:BoundField>
                                                    <asp:BoundField DataField="NOY" HeaderText="Course Year"></asp:BoundField>
                                                    <asp:BoundField DataField="SDATE" HeaderText="Assignment Date"></asp:BoundField>
                                                    <asp:ButtonField HeaderText="Edit" Text="Edit" CommandName="Edit" />
                                                    <asp:ButtonField HeaderText="Delete" Text="Delete" Visible="false" CommandName="Delete" />
                                                </Columns>
                                                <%--<FooterStyle BackColor="White" ForeColor="#000066" />
                                                <RowStyle ForeColor="#000066" />
                                                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" />
                                                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                                                <PagerSettings Mode="NumericFirstLast" />--%>
                                            </asp:GridView>
                                            <asp:Label ID="Label2" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <asp:Button ID="Button1" runat="server" Style="display: none;" OnClick="Button1_Click" />
                                            <asp:Button ID="Button3" runat="server" Visible="false" BorderColor="#FFFFFF" BackColor="#FFFFFF"

                                                ForeColor="#666930" BorderStyle="Solid" OnClick="Button3_Click" />
                                            <asp:Button ID="Button4" runat="server" Style="display: none;" OnClick="Button4_Click" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>

                    </table>
                </td>
            </tr>
        </table>
    </div>



</ContentTemplate>
<Triggers></Triggers>
</asp:UpdatePanel>
</asp:Content>

推荐答案

/g, ""); } function Ass() { var ay = document.getElementById('<%=DropDownList2.ClientID %>'); var co = document.getElementById('<%=DropDownList3.ClientID %>'); var yr = document.getElementById('<%=DropDownList4.ClientID %>'); var sem = document.getElementById('<%=DropDownList5.ClientID %>'); if (ay.selectedIndex == 0) { ay.style.background = 'Yellow'; alert("Please select the academic year !"); ay.focus(); 返回 ; } 其他 { ay.style.background = 'White'; } if (co.selectedIndex == 0) { co.style.background = 'Yellow'; alert("Please select the course !"); co.focus(); 返回 ; } 其他 { co.style.background = 'White'; } if (yr.selectedIndex == 0) { yr.style.background = 'Yellow'; alert("Please select the year !"); yr.focus(); 返回 ; } 其他 { yr.style.background = 'White'; } if (sem.selectedIndex == 0) { sem.style.background = 'Yellow'; alert("Please select the semester !"); sem.focus(); 返回 ; } 其他 { sem.style.background = 'White'; } } < / 脚本 > <asp:ScriptManager ID="scriptmanager" runat="server"></asp:ScriptManager> < asp:UpdatePanel ID =" runat 服务器" < ContentTemplate > < div =" > <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> < tr > <td width="95%" valign="top" bgcolor="#FFFFFF"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> < tr > <td width="100%" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="2" style="background-color: #ffffff"> < tr > < td =" center" <img src="images/Head/assg.PNG" /> < /td > < /tr > < tr > <td align="center" width="100%"> <table width="42%" align="center"> < tr > <td align="left" width="24%"> <asp:Label ID="Label3" runat="server" CssClass="lbl" Text="Academic Year"></asp:Label> < /td > <td align="left" width="2%"> : < /td > <td align="left" width="24%"> <asp:DropDownList ID="DropDownList2" runat="server" Width="120px"> < /asp:DropDownList > < /td > <td align="left" width="24%"> <asp:Label ID="Label4" runat="server" CssClass="lbl" Text="Course"></asp:Label> < /td > <td align="left" width="2%"> : < /td > <td align="left" width="24%"> <asp:DropDownList ID="DropDownList3" runat="server" Width="120px"> < /asp:DropDownList > < /tr > < tr > <td align="left" width="24%"> <asp:Label ID="Label5" runat="server" CssClass="lbl" Text="Year"></asp:Label> < /td > <td align="left" width="2%"> : < /td > <td align="left" width="24%"> <asp:DropDownList ID="DropDownList4" runat="server" Width="120px"> < /asp:DropDownList > < /td > <td align="left" width="24%"> <asp:Label ID="Label6" runat="server" CssClass="lbl" Text="Semester"></asp:Label> < /td > <td align="left" width="2%"> : < /td > <td align="left" width="24%"> <asp:DropDownList ID="DropDownList5" runat="server" Width="120px"> < /asp:DropDownList > < /td > < /tr > < tr > <td align="center" width="100%" colspan="6"> <asp:Button ID="Button5" runat="server" CssClass="Fetch" OnClientClick="return Ass()" span> OnClick="Button5_Click" /> < /td > < /tr > < /table > < /td > < /tr > < tr > < td =" center" < br > <asp:GridView ID="GridView1" runat="server" DataKeyNames="ALID" AutoGenerateColumns="False" span> Width="100%" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" BorderStyle="None" span> BorderWidth="1px" CellPadding="3" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" span> OnRowCommand="GridView1_RowCommand" OnRowEditing ="GridView1_RowEditing" OnRowDeleting="GridView1_RowDeleting"> < > < asp:TemplateField HeaderText =" > < ItemTemplate > <asp:Label ID="lblno" runat="server" Text='<%#Container.DataItemIndex+1 %>'></asp:Label> < /ItemTemplate > < /asp:TemplateField > <asp:BoundField HeaderText="S.No" Visible="false" DataField="ALID"></asp:BoundField> <asp:BoundField DataField="ACYEAR" HeaderText="Academic Year"></asp:BoundField> <asp:BoundField DataField="CNAME" HeaderText="Course Name"></asp:BoundField> <asp:BoundField DataField="NOY" HeaderText="Course Year"></asp:BoundField> <asp:BoundField DataField="SDATE" HeaderText="Assignment Date"></asp:BoundField> <asp:ButtonField HeaderText="Edit" Text="Edit" CommandName="Edit" /> <asp:ButtonField HeaderText="Delete" Text="Delete" Visible="false" CommandName="Delete" /> < /列 > <%--<FooterStyle BackColor="White" ForeColor="#000066"/> <RowStyle ForeColor="#000066"/> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White"/> <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center"/> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White"/> <PagerSettings Mode="NumericFirstLast"/>--%> < /asp:GridView > < asp:Label ID =" runat 服务器" < > < /td > < /tr > < tr > < td =" center" <asp:Button ID="Button1" runat="server" Style="display: none;" OnClick="Button1_Click" /> <asp:Button ID="Button3" runat="server" Visible="false" BorderColor="#FFFFFF" BackColor="#FFFFFF" span> ForeColor="#666930" BorderStyle="Solid" OnClick="Button3_Click" /> <asp:Button ID="Button4" runat="server" Style="display: none;" OnClick="Button4_Click" /> < /td > < /tr > < /table > < /td > < /tr > < /table > < /td > < /tr > < /table > < /div > < /ContentTemplate > <Triggers></Triggers> < /asp:UpdatePanel > < /asp:Content >
/g, ""); } function Ass() { var ay = document.getElementById('<%=DropDownList2.ClientID %>'); var co = document.getElementById('<%=DropDownList3.ClientID %>'); var yr = document.getElementById('<%=DropDownList4.ClientID %>'); var sem = document.getElementById('<%=DropDownList5.ClientID %>'); if (ay.selectedIndex == 0) { ay.style.background = 'Yellow'; alert("Please select the academic year !"); ay.focus(); return false; } else { ay.style.background = 'White'; } if (co.selectedIndex == 0) { co.style.background = 'Yellow'; alert("Please select the course !"); co.focus(); return false; } else { co.style.background = 'White'; } if (yr.selectedIndex == 0) { yr.style.background = 'Yellow'; alert("Please select the year !"); yr.focus(); return false; } else { yr.style.background = 'White'; } if (sem.selectedIndex == 0) { sem.style.background = 'Yellow'; alert("Please select the semester !"); sem.focus(); return false; } else { sem.style.background = 'White'; } } </script> <asp:ScriptManager ID="scriptmanager" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="updatepanel1" runat="server"> <ContentTemplate> <div style="width: 100%;"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="95%" valign="top" bgcolor="#FFFFFF"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="100%" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="2" style="background-color: #ffffff"> <tr> <td align="center"> <img src="images/Head/assg.PNG" /> </td> </tr> <tr> <td align="center" width="100%"> <table width="42%" align="center"> <tr> <td align="left" width="24%"> <asp:Label ID="Label3" runat="server" CssClass="lbl" Text="Academic Year"></asp:Label> </td> <td align="left" width="2%"> : </td> <td align="left" width="24%"> <asp:DropDownList ID="DropDownList2" runat="server" Width="120px"> </asp:DropDownList> </td> <td align="left" width="24%"> <asp:Label ID="Label4" runat="server" CssClass="lbl" Text="Course"></asp:Label> </td> <td align="left" width="2%"> : </td> <td align="left" width="24%"> <asp:DropDownList ID="DropDownList3" runat="server" Width="120px"> </asp:DropDownList> </tr> <tr> <td align="left" width="24%"> <asp:Label ID="Label5" runat="server" CssClass="lbl" Text="Year"></asp:Label> </td> <td align="left" width="2%"> : </td> <td align="left" width="24%"> <asp:DropDownList ID="DropDownList4" runat="server" Width="120px"> </asp:DropDownList> </td> <td align="left" width="24%"> <asp:Label ID="Label6" runat="server" CssClass="lbl" Text="Semester"></asp:Label> </td> <td align="left" width="2%"> : </td> <td align="left" width="24%"> <asp:DropDownList ID="DropDownList5" runat="server" Width="120px"> </asp:DropDownList> </td> </tr> <tr> <td align="center" width="100%" colspan="6"> <asp:Button ID="Button5" runat="server" CssClass="Fetch" OnClientClick="return Ass()" OnClick="Button5_Click" /> </td> </tr> </table> </td> </tr> <tr> <td align="center"> <br /> <asp:GridView ID="GridView1" runat="server" DataKeyNames="ALID" AutoGenerateColumns="False" Width="100%" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" BorderStyle="None" BorderWidth="1px" CellPadding="3" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowCommand="GridView1_RowCommand" OnRowEditing="GridView1_RowEditing" OnRowDeleting="GridView1_RowDeleting"> <Columns> <asp:TemplateField HeaderText="S.No"> <ItemTemplate> <asp:Label ID="lblno" runat="server" Text='<%#Container.DataItemIndex+1 %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField HeaderText="S.No" Visible="false" DataField="ALID"></asp:BoundField> <asp:BoundField DataField="ACYEAR" HeaderText="Academic Year"></asp:BoundField> <asp:BoundField DataField="CNAME" HeaderText="Course Name"></asp:BoundField> <asp:BoundField DataField="NOY" HeaderText="Course Year"></asp:BoundField> <asp:BoundField DataField="SDATE" HeaderText="Assignment Date"></asp:BoundField> <asp:ButtonField HeaderText="Edit" Text="Edit" CommandName="Edit" /> <asp:ButtonField HeaderText="Delete" Text="Delete" Visible="false" CommandName="Delete" /> </Columns> <%--<FooterStyle BackColor="White" ForeColor="#000066" /> <RowStyle ForeColor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" /> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /> <PagerSettings Mode="NumericFirstLast" />--%> </asp:GridView> <asp:Label ID="Label2" runat="server"></asp:Label> </td> </tr> <tr> <td align="center"> <asp:Button ID="Button1" runat="server" Style="display: none;" OnClick="Button1_Click" /> <asp:Button ID="Button3" runat="server" Visible="false" BorderColor="#FFFFFF" BackColor="#FFFFFF" ForeColor="#666930" BorderStyle="Solid" OnClick="Button3_Click" /> <asp:Button ID="Button4" runat="server" Style="display: none;" OnClick="Button4_Click" /> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </div> </ContentTemplate> <Triggers></Triggers> </asp:UpdatePanel> </asp:Content>


这篇关于为什么我在aspx源页面中插入了scriptmanager,updatepanel和内容模板后,为什么我的按钮事件和gridview编辑事件没有触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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