简体   繁体   English

使用C#的ASP.NET

[英]asp.net with c#

I have one page which is placed in the Master Page. 我在母版页中放置了一页。

In the master page i have 1 dropdown and one GridView, dropdown is display the category , based on the dropdown list selection it will display the list of videos in the Grid. 在主页中,我有1个下拉列表和一个GridView,下拉列表显示类别,基于下拉列表选择,它将显示Grid中的视频列表。

In the content page i have the video player, in the page load it will play the video by default. 在内容页面中,我有视频播放器,在页面加载中,它将默认播放视频。

But when i choose the drop down list which is available in the master page, the page is refreshing, SO the video is start play from the first. 但是,当我选择母版页中提供的下拉列表时,该页面正在刷新,因此视频从第一个开始播放。

The content page should not refresh, So the video will continuously play. 内容页面不应刷新,因此视频将连续播放。

So please advice how to stop the page refresh in the content page. 因此,请提出建议如何停止内容页面中的页面刷新。 please help me its urgent. 请帮助我紧急。

Thanks in Advance 提前致谢

All are in mater page 全部在母版页中

` `

                    <asp:DropDownList ID="drp_Channel" Width="220px" CssClass="ddl" 
                            AutoPostBack="true" runat="server" 
                            onselectedindexchanged="drp_Channel_SelectedIndexChanged">
                      <asp:ListItem>-- Select Channels --</asp:ListItem>
                      </asp:DropDownList>
                   </ContentTemplate>
                    </asp:UpdatePanel>

                            <asp:GridView ID="grd_Video" runat="server" AutoGenerateColumns="False" OnRowCommand="LinkName"
                            GridLines="None" ShowHeader="False" Width="100%" EmptyDataText="No Videos Found" >
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>

                                        <asp:ImageButton ID="img_Video" runat="server" BorderColor="#666699" CssClass="imgbox"
                                            ImageUrl='<%#(string)FormatImageUrl((string)Eval("Video_Thumbnail")) %>' 
                                            CommandName="imgClick" CommandArgument='<%# Bind("Video_ID")%>' 
                                            BorderWidth="0px" Height="40px" ToolTip="Click to view video" Width="50px" 
                                            BorderStyle="Double" />

                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                    <asp:LinkButton ID="lnk_VideoName" runat="server" ToolTip="Click to view video" 
                                            CommandName="lnkClick" CommandArgument='<%# Bind("Video_ID")%>' 
                                            Text='<%# DataBinder.Eval(Container, "DataItem.Video_Name") %>' 
                                            CssClass="linkVideo" Width="130px"></asp:LinkButton> 

                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <AlternatingRowStyle BackColor="#cccccc" />

                        </asp:GridView>
                        </ContentTemplate>
                            </asp:UpdatePanel>`

in code behind for binding grid, 在后面的用于绑定网格的代码中,

DataTable dt1Video = new MDBusiness.MDSUser().GetVideo(intNetId, intChanId, intCatId); DataTable dt1Video =新的MDBusiness.MDSUser()。GetVideo(intNetId,intChanId,intCatId); grd_Video.DataSource = dt1Video; grd_Video.DataSource = dt1Video; grd_Video.DataBind(); grd_Video.DataBind(); up1.Update(); up1.Update(); up2.Update(); up2.Update();

Set AutoPostBack = "False" on your dropdownlist to stop the postback from occurring. 在下拉列表上设置AutoPostBack = "False" ,以阻止回发。 Users will then be able to change the dropdownlist without anything happening. 然后,用户将能够更改下拉列表,而不会发生任何事情。

You'll need to use AJAX with your dropdownlist if you want to be able to use it without the postback. 如果您希望不带回发就可以使用它,则需要在下拉列表中使用AJAX。

for a quick answer 快速回答

  • Install ASP.NET AJAX library 安装ASP.NET AJAX库
  • Wrap the GridView in a UpdatePanel 将GridView包装在UpdatePanel中
  • Set the trigger to be the DropDownList 将触发器设置为DropDownList

Done :) 完成:)

Remember to see this Screencast ... it is exactly what you are after! 记住要看这个截屏视频 ……这正是您所追求的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM