如何阻止面板2和显示面板1 [英] How to block the panel 2 and display the panel1

查看:68
本文介绍了如何阻止面板2和显示面板1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在项目中使用了两个面板和两个模式弹出扩展器.在面板1中,我按下添加文档按钮.它显示两个面板,分别带有文件上传和一个上传按钮.在此期间,我将阻止panel1并显示面板2.当我上传文件时,它将进入主窗口.在这里我要显示面板.而且,当我按下面板2中的重置按钮时,它想要清除panel2和要显示的面板2中的字段,但此处转到主窗口.谁能帮我解决这个问题.这是代码:


Hi,

I am using two panels and two modal popup extender in my Project. In panel 1 I am pressing the add document button It displays the panel two with file upload and a upload button. During that time I am blocking the panel1 and displaying the panel 2. When I uploading the file it goes to the main window. Here I want to display the panel. And When I press the reset button in panel 2 it want to clear the fields in panel2 and the panel 2 to be displayed but here it goes to the main window. Can any one help me to solve this problem. Here is the code:


<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="true" CodeFile="FileUpload.aspx.cs" Inherits="FileUpload" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
   .modalBackground {
z-index:10;
display:block;
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
margin: 0px 0px 0px 0px;
}
    </style>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script language="javascript" type="text/javascript" >
        function confirm_delete()
        {
            if (confirm("Are you sure you want to remove selected file?") == true)
                return true;
            else
                return false;
        }
        function hideModal() {
            document.getElementById('Panel1').style.display = 'none';
        }
        function hidepanel2() {
            document.getElementById('Panel2').style.display = 'none';
            document.getElementById('Panel1').style.display = 'block';
        }
            </script>
</head>
<body style="height: 906px; width: 1058px;">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:ImageButton id="AttachDoc" runat="server" ImageUrl="~/images/scholar.gif"></asp:ImageButton>
<asp:LinkButton id="AttachDocument" runat="server" Font-Bold="False">Attach Document</asp:LinkButton>
</div>
<asp:Panel ID="Panel1" runat="server" BackColor="White">
<table id="tblDetail1" runat="server" border="1" cellspacing="0" visible="true">
            <tr>
                <td align="center" colspan="2" bgcolor="#009933">
                    <asp:Label ID="Label8" runat="server" Text="Attach Document" ForeColor="Black"

                        style="font-weight: 700"></asp:Label></td>
            </tr>
            <tr>
                <td align="left">
                    <asp:Label ID="Label9" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="X-Small"

                        Text="Key Data: " Width="100px"></asp:Label>
                    <asp:Label ID="lblKey" runat="server" Font-Names="Verdana" Font-Size="X-Small" ForeColor="Blue"

                        Style="text-align: left"></asp:Label></td>
                <td align="left" colspan="1">
                    <asp:Label ID="Label11" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="X-Small"

                        Text="Description: " Width="100px"></asp:Label>
                    <asp:Label ID="lblDesc" runat="server" Font-Names="Verdana" Font-Size="X-Small" ForeColor="Blue"

                        Style="text-align: left"></asp:Label></td>
            </tr>
            <tr>
                <td align="left" colspan="2">
                    <asp:Label ID="lblmsg" runat="server" Font-Bold="True"

                        ForeColor="Red" TabIndex="-1"></asp:Label></td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"

                        AutoGenerateColumns="False" align="center" EmptyDataText="No Documents Added" GridLines="Vertical"

                        Width="988px" style="margin-bottom: 0px">
                        <PagerSettings FirstPageText="First" LastPageText="Last" Mode="NextPreviousFirstLast"

                            NextPageText="Next" PreviousPageText="Previous" />
                        <EmptyDataRowStyle/>
                        <Columns>
                            <asp:TemplateField HeaderText="Sl No">
                                <ItemTemplate>
                                    &nbsp;<asp:Label ID="lblCol0" runat="server" Font-Names="Verdana" Font-Size="XX-Small"><%# DataBinder.Eval(Container.DataItem, "slNo1") %></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Right" Width="60px" />
                                <ItemStyle HorizontalAlign="Right" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Document Type">
                                <ItemTemplate>
                                    <asp:Label ID="lblDocType" runat="server" Font-Names="Verdana" Font-Size="XX-Small"><%#DataBinder.Eval(Container.DataItem, "document_type")%></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="File Name">
                                <ItemTemplate>
                                    <asp:Label ID="lnkFileName" runat="server" Font-Names="Verdana" Font-Size="XX-Small"

                                        Width="50px" Text='<%# DataBinder.Eval(Container.DataItem, "fileName") %>' ></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle Width="300px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Description">
                                <ItemTemplate>
                                    <asp:Label ID="lblCol2" runat="server" Font-Names="Verdana" Font-Size="XX-Small"><%# DataBinder.Eval(Container.DataItem, "desc") %></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Keyword">
                                <ItemTemplate>
                                    <asp:Label ID="lblKeyword" runat="server" Font-Names="Verdana" Font-Size="XX-Small"><%# DataBinder.Eval(Container.DataItem, "Keyword") %></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Uploaded Date">
                                <ItemTemplate>
                                    <asp:Label ID="lblCol22" runat="server" Font-Names="Verdana" Font-Size="XX-Small"><%# DataBinder.Eval(Container.DataItem, "date") %></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Right" />
                                <ItemStyle HorizontalAlign="Right" />
                            </asp:TemplateField>
                            <asp:CommandField SelectText="View Document" ShowSelectButton="True" HeaderText="View">
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:CommandField>
                            <asp:TemplateField HeaderText="code" Visible="False">
                                <ItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "slNo")%>'

                                        Visible="False" Width="88px"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="file" Visible="False">
                                <ItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "fileName")%>'

                                        Visible="False"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="view" Visible="False"></asp:TemplateField>
                            <asp:TemplateField HeaderText="Remove">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkRemove" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "keydata_slno")%>' CommandName="Remove">Remove Document</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle HorizontalAlign="Left" Wrap="False" />
                        <SelectedRowStyle />
                        <HeaderStyle BackColor="#009933" />
                        <AlternatingRowStyle />
                    </asp:GridView>
                    <asp:Button ID="AddDocument" runat="server" OnClientClick="hideModal()"

                        Text="Add Document" onclick="AddDocument_Click" BackColor="#009933"/>
                    &nbsp;
                   <asp:Button ID="Panel1Close" runat="server" Text="Close" BackColor="#009933" />

                    <asp:ModalPopupExtender ID="Linkbutton_ModalPopupExtender" runat="server"

                        TargetControlID="AttachDocument" PopupControlID="Panel1"

                        BackgroundCssClass="modalBackground">
                    </asp:ModalPopupExtender>
                </td>
            </tr>
        </table>
</asp:Panel>
<asp:Panel ID="panel2" runat="server" style="margin-right: 494px"

    BackColor="White">
<table id="Table4" runat="server" border="1" cellspacing="0" visible="true">
            <tr>
                <td align="center" bgcolor="#009933">
                    <asp:Label ID="Label1" runat="server" Text="Add File" ForeColor="Black"

                        style="font-weight: 700"></asp:Label></td>
            </tr>
            <tr>
                <td>
                    <table cellspacing="0" id="TABLE5" runat="server">
                        <tr>
                            <td align="right">
                                <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="X-Small"

                                    Text="*Document Type:"></asp:Label></td>
                            <td align="left">
                                                            <asp:DropDownList ID="DocType" runat="server" Height="16px" Width="102px">
                                                                <asp:ListItem Value="G">General</asp:ListItem>
                                                                <asp:ListItem Value="B">Bid</asp:ListItem>
                                                            </asp:DropDownList>

                                                            </td>
                        </tr>
                                                <tr>
                            <td align="right">
                                <asp:Label ID="Label3" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="*Description:" Font-Bold="True"></asp:Label></td>
                            <td class="style3">
                                <input id="Description" type="text" style="font-size: x-small; width: 450px; font-family: Verdana" runat="server" maxlength="100" /></td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="X-Small"

                                    Text="Keywords"></asp:Label></td>
                            <td align="left" class="style3">
                                <input id="Keywords" type="text" style="font-size: x-small; width: 450px; font-family: Verdana" runat="server" maxlength="100" /></td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="Label5" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="File Name*:" Font-Bold="True"></asp:Label></td>
                            <td class="style3">
                                <asp:FileUpload ID="FileUpload4" runat="server" />
                            </td>
                        </tr>
                    </table>
                    <asp:Label ID="Label15" runat="server" Font-Names="Verdana" Font-Size="X-Small" ForeColor="Black"

                        Width="546px"></asp:Label></td>
            </tr>
            <tr>
                <td align="center">
                    &nbsp; &nbsp;&nbsp;
                    <asp:Button ID="UploadButton" runat="server" Text="Upload"

                        onclick="UploadButton_Click" BackColor="#009933"

                        />
                    <input type='button' id="BackButton" onclick='hidepanel2()' value="Back" style="background-color: #009933"/>
                    <asp:Button ID="ResetButton" runat="server" Text="Reset"

                        onclick="ResetButton_Click" BackColor="#009933" />
                    </td>
            </tr>
            <tr>
                <td align="left" >
        <asp:Label ID="lblMsg1" runat="server" Font-Names="Verdana" Font-Size="Small" ForeColor="Red"

            Style="left: 191px; position: static; top: 219px" Visible="False" Width="546px"></asp:Label></td>
            </tr>
        </table>
                <asp:ModalPopupExtender ID="AddDocument_ModalPopupExtender" runat="server"

                        TargetControlID="AddDocument" PopupControlID="Panel2"

        BackgroundCssClass="modalBackground">
                    </asp:ModalPopupExtender>
</asp:Panel>

</form>
</body>
</html>





Thanks in advance





Thanks in advance

推荐答案

Why not tag your question so it is what you claimed it to be ?

You set the visibility of your panels to show or hide them. You posted a description of a basic task, and a ton of code. What exactly is the problem ?
Why not tag your question so it is what you claimed it to be ?

You set the visibility of your panels to show or hide them. You posted a description of a basic task, and a ton of code. What exactly is the problem ?


Change these two function slightly because the IDs of the controls are changes afetr rendering

Change these two function slightly because the IDs of the controls are changes afetr rendering

function hideModal() {
            document.getElementById('<%= Panel1.ClientID %>').style.display = 'none';
        }
        function hidepanel2() {
            document.getElementById('<%= Panel2.ClientID %>').style.display = 'none';
            document.getElementById('<%= Panel1.ClientID %>').style.display = 'block';
        }


这篇关于如何阻止面板2和显示面板1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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