SelectedIndexChange没有发射 [英] SelectedIndexChange Not Firing

查看:135
本文介绍了SelectedIndexChange没有发射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DropDownList的问题更新一个文本框,既是一个列表视图内举行,更新面板这又是在一个项目模板中。

更新

我有这个工作具有相同的code,而不在同一个项目中的不同网页上面的容器,但遇到了麻烦与lisview等容器结合起来。

我无法确定问题所在,onClick的在不触发,除非有一个回调到服务器,不管下包含上述容器内的下降。

任何帮助将是很大的AP preciated,在此先感谢。

使用ASP(1日)和VB code背后(2日)。

 < InsertTemplate则>
< ASP:面板=服务器ChildrenAsTriggers =真的UpdateMode =始终>
< ASP:ListView控件ID =ListView1的=服务器InsertItemPosition =与firstItemIAllowPaging =真的EnableViewState =真正的>
&其中; TR>
< TD>
< ASP:文本框ID =TextBox2中=服务器文本='<%#绑定(细则)%GT;文本模式=多行/>
< / TD>
< TD>
< ASP:DropDownList的ID =DLL=服务器OnSelectedIndexChanged =DLL_SelectedIndexChanged的AutoPostBack =真的EnableViewState =真正的>
    < ASP:列表项>选择< / ASP:列表项>
    &所述; asp的:列表项值=1>是&所述; / asp的:列表项>
    < ASP:列表项值=2>不< / ASP:列表项>
    < ASP:列表项值=3>也许< / ASP:列表项>
    < ASP:列表项值=4>我不知道< / ASP:列表项>
    < ASP:列表项值=5>你能重复< / ASP:列表项>
    < ASP:列表项值=6>该问题与LT; / ASP:列表项>
< / ASP:DropDownList的>
< / TD>
< / TR>
< / ASP:面板>
< / InsertTemplate则>
 

$ C $后面

ç

 保护小组DDL_SelectedIndexChanged(发送者为对象,E作为EventArgs的)

    昏暗的DDL作为DropDownList的= DirectCast(发件人,DropDownList的)
    昏暗listviewItemThing = DirectCast(sender.parent.NamingContainer,ListViewItem的)
    昏暗的TB作为文本框= DirectCast(ddl.NamingContainer.FindControl(TextBox2中),文本框)

    如果ddl.SelectedValue = 1,则
        tb.Text = My.Computer.FileSystem.ReadAllText(E:\用户\韩\文件\模板\ 1.TXT)
    elseif的ddl.SelectedValue = 2那么
        tb.Text = My.Computer.FileSystem.ReadAllText(E:\用户\韩\文件\模板\ 2.txt)
    elseif的ddl.SelectedValue = 3然后
        tb.Text = My.Computer.FileSystem.ReadAllText(E:\用户\韩\文件\模板\ 3.txt)
    elseif的ddl.SelectedValue = 4那么
        tb.Text = My.Computer.FileSystem.ReadAllText(E:\用户\韩\文件\模板\ 4.txt)
    elseif的ddl.SelectedValue = 5然后
        tb.Text = My.Computer.FileSystem.ReadAllText(E:\用户\韩\文件\模板\ 5.txt)
    elseif的ddl.SelectedValue = 6于是,
        tb.Text = My.Computer.FileSystem.ReadAllText(E:\用户\韩\文件\模板\ 6.txt)
    其他
        tb.Text =
    结束如果
结束小组
 

更新2

根据要求请参见附件截屏浏览器控制台错误调试的VS2013

和扩展的错误。

更新3

补充jQuery来试图强迫回发。

 函数JsFunction(){
         __doPostBack('DLL_SelectedIndexChanged','');
     }
 

ASP链接JQ

 < ASP:DropDownList的ID =DDL=服务器WIDTH =120pxOnSelectedIndexChanged =DDL_SelectedIndexChanged的AutoPostBack =真的CausesValidation =假的EnableViewState =真的onchange =JavaScript的:JsFunction()>
 

解决方案

您有正确的$ C $下您的下拉列表中,这样的错误在其他地方。

正如你在错误信息看:当您尝试使用 HtmlEditorExtender 提交表单的问题
所以只要删除或禁用它快速修复问题。

至于与 HtmlEditorExtender 的错误,我们需要一点点信息,当然,如果你还需要解决它。

I'm having issue with a dropdownlist updating a textbox, both held within a listview, within an update panel which in turn is in an item template.

Updated

I have got this working with the same code without the above containers in a different web page on the same project, however having trouble linking it with the lisview and other containers.

I am unsure of where the problem lies, the onClick isn't firing unless there's a call back to the server, regardless whether the drop down is contained within the containers mentioned above.

Any help would be greatly appreciated, thanks in advance.

Using asp (1st) and VB code behind (2nd).

<InsertItemTemplate>
<asp:panel runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<asp:ListView ID="ListView1" runat="server" InsertItemPosition="FirstItem" IAllowPaging="True" EnableViewState="true">
<tr>
<td>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Details")%>' TextMode="MultiLine" />
</td>
<td>
<asp:DropDownList ID="DLL" runat="server" OnSelectedIndexChanged="DLL_SelectedIndexChanged" AutoPostBack="true "EnableViewState="true">
    <asp:ListItem>Select</asp:ListItem>
    <asp:ListItem Value="1">Yes</asp:ListItem>
    <asp:ListItem Value="2">No</asp:ListItem>
    <asp:ListItem Value="3">Maybe</asp:ListItem>
    <asp:ListItem Value="4">I dont know</asp:ListItem>
    <asp:ListItem Value="5">Can you repeat</asp:ListItem>
    <asp:ListItem Value="6">the question</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</asp:panel>
</InsertItemTemplate>

Code behind

    Protected Sub DDL_SelectedIndexChanged(sender As Object, e As EventArgs)

    Dim ddl As DropDownList = DirectCast(sender, DropDownList) 
    Dim listviewItemThing = DirectCast(sender.parent.NamingContainer, ListViewItem) 
    Dim tb As TextBox = DirectCast(ddl.NamingContainer.FindControl("TextBox2"), TextBox)

    If ddl.SelectedValue = 1 Then
        tb.Text = My.Computer.FileSystem.ReadAllText("E:\Users\han\Documents\Templates\1.txt")
    ElseIf ddl.SelectedValue = 2 Then
        tb.Text = My.Computer.FileSystem.ReadAllText("E:\Users\han\Documents\Templates\2.txt")
    ElseIf ddl.SelectedValue = 3 Then
        tb.Text = My.Computer.FileSystem.ReadAllText("E:\Users\han\Documents\Templates\3.txt")
    ElseIf ddl.SelectedValue = 4 Then
        tb.Text = My.Computer.FileSystem.ReadAllText("E:\Users\han\Documents\Templates\4.txt")
    ElseIf ddl.SelectedValue = 5 Then
        tb.Text = My.Computer.FileSystem.ReadAllText("E:\Users\han\Documents\Templates\5.txt")
    ElseIf ddl.SelectedValue = 6 Then
        tb.Text = My.Computer.FileSystem.ReadAllText("E:\Users\han\Documents\Templates\6.txt")
    Else
        tb.Text = ""
    End If
End Sub

Update 2

As per request please see attached screen shot of browser console error in debug on VS2013

And expanded error.

Update 3

Added JQuery to try to force PostBack.

         function JsFunction() {
         __doPostBack('DLL_SelectedIndexChanged', '');
     }

ASP link to JQ

<asp:DropDownList ID="DDL" runat="server" Width="120px" OnSelectedIndexChanged="DDL_SelectedIndexChanged" AutoPostBack="true" CausesValidation="false" EnableViewState="true" onchange="javascript:JsFunction()">

解决方案

You have correct code for your drop down list, so error in other place.

As you see in error message: when you try submit form problem with HtmlEditorExtender.
So just remove or disable it for quick fixing problem.

As for error with HtmlEditorExtender we need a little bit information, of course, if you still need solve it.

这篇关于SelectedIndexChange没有发射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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