English 中文(简体)
ASP.NET清单
原标题:ASP.NET listbox MaintainScrollPositionOnPostBack re-ordering items near bottom reloads listbox at top

I ve got a ASP. NET (VB) page with two list Boxes. 标准 st子——选择左边的物品,打上加顿,走到右边等。 我也用两顿子把物品移至或缩小后的清单。 我的问题是,如果我去谈谈最后一个项目(或这一范围的任何项目),将其从名单上剔除,就把滚动障碍降为最高职位。 我想把重点放在促进或推动的项目上,而不论它是否“ath”。

我在我的网页上宣布了“维持ScrollPositionOnPostBack”,这对整个网页来说是巨大的,尽管对清单箱没有作用,但这是我所期望的行为类型。 能否在VB中做到这一点,而不诉诸Javascript或AJAX?

事先感谢您可能提出的任何想法或建议。 法典如下:

If lstToFields.SelectedIndex < lstToFields.Items.Count - 1 Then
    Dim RowNum As Integer = lstToFields.SelectedIndex
    Dim RowVal As ListItem = lstToFields.SelectedItem
    lstToFields.Items.RemoveAt(RowNum)
    lstToFields.Items.Insert(RowNum + 1, RowVal)
    lstToFields.SelectedIndex = RowNum + 1
End If
问题回答

你的问题似乎与我最近的问题相似。 我倾向于说,邮政局是你的问题,你必须用贾瓦文处理雕像。 我的解决办法如下:

Create a HiddenField in the ASPX page to hold the current position of the ScrollBar.


< asp : HiddenField ID ="hdnScollTop" EnableViewState =true runat="server" />

• 建立 Java台功能,以节约和装上黑色地带的价值。 我还有一个更新名单的功能,我不得不用于我的多语言名单Box。




function Updatelist() {
    //details removed
} 
function GetListBoxScrollPosition(){
    var sel = document.getElementById( <%=lstbxStuff.ClientID%> ); 
    var hdnScrollTop = document.getElementById( <%=hdnScollTop.ClientID %> );
    hdnScrollTop.innerText=sel.scrollTop;
}
function SetListBoxScrollPosition(){
    var sel = document.getElementById( <%=lstbxStuff.ClientID%> ); 
    var hdnScrollTop = document.getElementById( <%=hdnScollTop.ClientID %> );
    sel.scrollTop=hdnScrollTop.value; //not sure why it s in value when I clearly put it in innerText. This is what works.
}


In Form_Load, register the JavaScript functions, and initialize the HiddenField Value. In the code-behind s Page_Load I set all of the scripts.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindACLs();
            //I use the hidden field to set the lstbxStuff 
            //scroll bar, which will scroll to the top anyway. 
            //This is to avoid a JavaScript error. 
            hdnScollTop.Value = "0";
        }
        else
        {
            lstbxStuff.Focus();
        }
        lstbxACLs.Attributes.Add("onclick", "GetListBoxScrollPosition();Updatelist();");
        lstbxACLs.Attributes.Add("onfocus", "SetListBoxScrollPosition();");


    }




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签