0

このフォームは正常に動作しますが、ドロップダウン ボックスを選択するたびにスクロールし、一番上までスクロールします。

<asp:UpdatePanel ID="updGridViewSMS" runat="server" UpdateMode="Conditional">
          <ContentTemplate>
            <label><b>Search By Date Range</b></label>
            <asp:Label ID="lblDateFrom" runat="server" Text="From"></asp:Label>
            <asp:TextBox ID="txtFromDate" runat="server" ></asp:TextBox>                      
            <asp:CalendarExtender ID="CalendarExtenderFromDate" Format="dd/MMM/yyyy" TargetControlID="txtFromDate" runat="server">
            </asp:CalendarExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" 
                                ControlToValidate="txtFromDate" Display="None" ErrorMessage="" 
                                ForeColor="Red" >
            </asp:RequiredFieldValidator>
            <asp:Label ID="lblDateTo" runat="server" Text="To"></asp:Label>
            <asp:TextBox ID="txtToDate" runat="server"></asp:TextBox>
            <asp:CalendarExtender ID="CalendarExtenderToDate" Format="dd/MMM/yyyy" TargetControlID="txtToDate" runat="server">
            </asp:CalendarExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" 
                                ControlToValidate="txtToDate" Display="None" ErrorMessage="" 
                                ForeColor="Red" >
            </asp:RequiredFieldValidator>
            <asp:Button ID="btnSearchByDate"  CssClass="btn btn-success" runat="server" Text="Search" 
                        ClientIDMode="Static"  OnClick="btnSearchByDate_Click" />
            &nbsp; 
            <%--<asp:Button ID="btnEdit"  CssClass="btn btn-success" runat="server" Text="Edit" 
                        ClientIDMode="Static" OnClick="btnEdit_Click"  />--%>

            <asp:ValidationSummary
             HeaderText="Requires Date Range:"
             DisplayMode="SingleParagraph"
             EnableClientScript="true"
             ForeColor="Red"
             runat="server" ID="ValidationSummary1"/>
           <label runat="server" id="lblSelectionMessage" style="color:navy; font-size:12px; font-style:italic" visible="false">

           </label>
           <asp:GridView ID="GridViewSmsComplaints" AllowPaging="True" PageSize="5" runat="server" AutoGenerateColumns="False"   Width="1085px" OnRowDataBound="GridViewSmsComplaints_RowDataBound" OnPageIndexChanging="GridViewSmsComplaints_PageIndexChanging" CellPadding="4" Height="417px" ForeColor="#333333" GridLines="None" >
               <FooterStyle BackColor="#990000" ForeColor="White" Font-Bold="True" />
               <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
               <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <PagerTemplate>
            <table>
                <tr>
                    <td>
                        <asp:LinkButton ID="lnkFirstPage" CommandName="Page" CommandArgument="First" runat="server">First</asp:LinkButton>
                    </td>
                    <td>
                        <asp:LinkButton ID="lnkNextPage" CommandName="Page" CommandArgument="Next" runat="server">Next</asp:LinkButton>
                    </td>
                    <td>
                        <asp:LinkButton ID="lnkPrevPage" CommandName="Page" CommandArgument="Prev" runat="server">Previous</asp:LinkButton>
                    </td>
                    <td>
                        <asp:LinkButton ID="lnkLastPage" CommandName="Page" CommandArgument="Last" runat="server">Last</asp:LinkButton>
                    </td>
                </tr>
            </table>
        </PagerTemplate>
               <AlternatingRowStyle BackColor="White" />
               <Columns>
                    <asp:BoundField HeaderText="Sms ID" DataField="ID" /> 
                    <asp:BoundField HeaderText="Recieving Date" DataField="RecievingDate" />  
                    <%--<asp:BoundField HeaderText="ToMobileNo" DataField="ToMobileNo" />  --%>
                    <asp:BoundField HeaderText="Complainant Mob No." DataField="FromMobileNo" /> 
                    <asp:BoundField HeaderText="Complaint" DataField="Message" >   
                     <ItemStyle Wrap="True" />
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Complete/InComplete">
                     <ItemTemplate>
                       <%--<asp:CheckBox ID="ckboxIsComplaint"  runat="server" />--%>
                       <asp:DropDownList ID="ddlIsComplaint" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlIsComplaint_SelectedIndexChanged">
                        <asp:ListItem Text="-Select-" Value="-1"></asp:ListItem>
                        <asp:ListItem Text="InComplete" Value="0"></asp:ListItem>
                        <asp:ListItem Text="Complete" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Inappropriate" Value="-3"></asp:ListItem>
                       </asp:DropDownList>
                     </ItemTemplate>
                    </asp:TemplateField>
               </Columns>
               <RowStyle ForeColor="#333333" BackColor="#FFFBD6" />
               <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
               <SortedAscendingCellStyle BackColor="#FDF5AC" />
               <SortedAscendingHeaderStyle BackColor="#4D0000" />
               <SortedDescendingCellStyle BackColor="#FCF6C0" />
               <SortedDescendingHeaderStyle BackColor="#820000" />
            </asp:GridView>    

        <br />
      <asp:Panel ID="pnlBoxesDropDowns" runat="server">
        <label>Complainant</label>
        <asp:TextBox ID="txtComplainant" runat="server" ></asp:TextBox>
        <asp:RequiredFieldValidator ID="ReqFieldValdiatorComplainant" runat="server" ControlToValidate="txtComplainant" ErrorMessage="Complainant is Required" ForeColor="Red" SetFocusOnError="True" ValidationGroup="Complaints">Complainant is Required
        </asp:RequiredFieldValidator>
        <label>Relevant Region</label>
        <asp:DropDownList ID="ddlRegions" runat="server" CssClass="DropDown_Width" Width="147px" OnSelectedIndexChanged="ddlRegions_SelectedIndexChanged" AppendDataBoundItems="True"  AutoPostBack="true" >
          <asp:ListItem Value="-1" Selected="True">-Select-</asp:ListItem>
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="ReqFieldValidatorRegions" runat="server" 
         ControlToValidate="ddlRegions" ErrorMessage="Region is Required" InitialValue="-1"
         ForeColor="Red" ValidationGroup="Complaints">Region is Required</asp:RequiredFieldValidator>
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:Label ID="lblRelevantDistrict" runat="server">District</asp:Label> 
        <asp:DropDownList ID="ddlDistricts" runat="server" CssClass="DropDown_Width" Width="127px" OnSelectedIndexChanged="ddlDistricts_SelectedIndexChanged" AutoPostBack="true">
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="ReqFieldValidatorDistricts" runat="server" 
         ControlToValidate="ddlDistricts" ErrorMessage="Region is Required" InitialValue="-1"
         ForeColor="Red" ValidationGroup="Complaints">District is Required</asp:RequiredFieldValidator>
       <label>Relevant P.Station</label> 
        <asp:DropDownList ID="ddlPoliceStations" AutoPostBack="true" runat="server" Width="147px" CssClass="DropDown_Width" OnSelectedIndexChanged="ddlPoliceStations_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="ReqFieldValidatorPoliceStations" runat="server" 
         ControlToValidate="ddlPoliceStations" ErrorMessage="Police Station is Required" InitialValue="-1"
         ForeColor="Red" ValidationGroup="Complaints">Police Station is Required</asp:RequiredFieldValidator>
          <asp:label ID="lblPriority" runat="server">Priority</asp:label>
          <asp:DropDownList ID="ddlPriority" runat="server" Width="127px">
              <asp:ListItem Text="Top" Value="1"></asp:ListItem>
              <asp:ListItem Text="Normal" Value="2"></asp:ListItem>
          </asp:DropDownList>
          &nbsp;
        </asp:Panel>
        <br />
        <br />
            <asp:Timer runat="server" Enabled="false" Interval="240000" ID="RefreshSmsComplaints" OnTick="RefreshSmsComplaints_Tick" />
          </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="RefreshSmsComplaints" EventName="Tick" />
            </Triggers>
         </asp:UpdatePanel>
        <asp:Button ID="btnDone" ValidationGroup="Complaints"  runat="server" CssClass="btn btn-success"  
            OnClick="btnDone_Click" Text="Done" />

コードビハインド:

    protected void ddlRegions_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Loads Districts Drop Down List When Relevant Region is Clicked
        ddlDistricts.Visible = true;
        lblRelevantDistrict.Visible = true;
        GridViewSmsComplaints.Visible = true;

        try
        {
            if (ddlDistricts.SelectedValue == "0")
            {
                ddlDistricts.SelectedValue = "-1";
            }
            else
            {
                ddlDistricts.DataTextField = "Name";
                ddlDistricts.DataValueField = "DistrictID";
                ddlDistricts.DataSource = mngRecievedMsg.FillDropDown_Districts(Convert.ToInt16(ddlRegions.SelectedValue));
                ddlDistricts.DataBind();
                ListItem list = new ListItem("-Select-", "-1");
                ddlDistricts.Items.Insert(0, list);
            }
        }
        catch (Exception) 
        {

        }

    }
    protected void ddlDistricts_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Loads police Stations Drop Down List When Relevant Region is Clicked

        updGridViewSMS.Visible = true; 
        try
        {
            if (ddlPoliceStations.SelectedValue == "0")
            {
                ddlPoliceStations.SelectedValue = "-1";
            }
            else
            {
                ddlPoliceStations.DataTextField = "Name";
                ddlPoliceStations.DataValueField = "ID";
                ddlPoliceStations.DataSource = mngRecievedMsg.GetHomePoliceStation(Convert.ToInt16(ddlDistricts.SelectedValue));
                ddlPoliceStations.DataBind();
                ListItem list_2 = new ListItem("-Select-", "-1");
                ddlPoliceStations.Items.Insert(0, list_2);
            }
        }
        catch (Exception) 
        {

        }


    }

    protected void ddlPoliceStations_SelectedIndexChanged(object sender, EventArgs e)
    {
        lblPriority.Visible = true;
        ddlPriority.Visible = true;
        ddlDistricts.Visible = true;
    }
4

3 に答える 3

0

ajax カスケード ドロップダウンを使用することをお勧めします

それを使用することで、ポストバックを起動せずにバインディングを達成できます

このリンクをたどってください

http://www.ajaxcontroltoolkit.com/CascadingDropDown/CascadingDropDown.aspx

これがあなたに役立つことを願っています

于 2014-11-06T11:16:58.153 に答える
-2

Ok。

この機能を IE でのみテストしている場合は、問題なく動作するはずです。ただし、Chrome の場合は、次の手順を実行する必要があります。

this.MaintainScrollPositionOnPostBack = true;

また、手順を参照してください。:-

プロジェクトを右クリックします。
「追加」→「新しいアイテムを追加」をクリックします。「新しい項目の追加」ウィンドウで、「ブラウザ ファイル」を選択し、「追加」をクリックします。アプリケーションは、このファイルを「App_Browsers」フォルダーに配置するように求めます。「はい」をクリックします。次のように、スクロール位置を維持する機能を追加します。

<browsers>
    <browser refID="Safari1Plus">
            <capabilities>
                <capability name="supportsMaintainScrollPositionOnPostback" 
                    value="true" />
            </capabilities>
    </browser>

于 2014-11-06T11:24:18.450 に答える