链接地址http://bbs.csdn.net/topics/390377663?page=1#post-393784355
帮忙看看一下哪里错了!

解决方案 »

  1.   

    这是我debug时 "#" + linkTypes 的值:
    #ctrl1_FLogoURLTextBox
    我发现$("#" + linkTypes).css("background", "Red");等都不行,也就是说无法对这个控件操纵。
    他解析引擎解析到浏览器的参数为:
    onchange="linkTypeChange(this,'ctrl1_FLogoURLTextBox')">
    崩溃。···
      

  2.   

    1、jquery的函数:function linkTypeChange(src, linkTypes) {
    if ($(src).val() == "text") {
    $("#" + linkTypes).css("background", "Red");
    } else if ($(src).val() == "pic") {
    $("#" + linkTypes).css("background", "Blue");
    }
    }
    2、后台ItemCreated代码:
    //插入或编辑时.
    if (e.Item.ItemType == ListViewItemType.DataItem || e.Item.ItemType == ListViewItemType.InsertItem) {
    //找到链接类型的DropDownList.
    DropDownList ddListLinkType = (DropDownList) e.Item.FindControl ("ddListLinkType");
    //找到显示类型的logo地址的控件.
    TextBox FLogoURLTextBox = (TextBox) e.Item.FindControl ("FLogoURLTextBox"); if (ddListLinkType != null && FLogoURLTextBox != null) {
    ddListLinkType.Attributes["onchange"] = "linkTypeChange(this,'" + FLogoURLTextBox.ClientID + "')"; if (ddListLinkType.SelectedValue == "text") { //如果类型是文件,logo地址隐藏.
    FLogoURLTextBox.Style["display"] = "none"; //设置style而不是属性.
    }
    else if (ddListLinkType.SelectedValue == "pic") { //如果类型是图片,logo地址显示.
    FLogoURLTextBox.Style["display"] = "";
    }
    else {
    throw new Exception ("未知");
    }
    }
    }
    3、ListView中InsertTemplate中待隐藏的TextBox:
    <asp:DropDownList ID="ddListLinkType" ValidationGroup="edit" runat="server">
    <asp:ListItem Value="text">文本</asp:ListItem>
    <asp:ListItem Value="pic">图片</asp:ListItem>
    </asp:DropDownList><asp:TextBox ID="FLogoURLTextBox" runat="server" ValidationGroup="edit" 
    Text='<%# Bind("FLogoURL") %>' />
    4.需求:DropDownList为“文本”时,隐藏TextBox(FLogoURLTextBox).
      

  3.   


    1、jquery方法:
    function linkTypeChange(src, linkTypes) {
    if ($(src).val() == "text") {
    $("#" + linkTypes).hide();
    } else if ($(src).val() == "pic") {
    $("#" + linkTypes).show();
    }
    }
    2、后台ItemCreated代码:
    //插入或编辑时.
    if (e.Item.ItemType == ListViewItemType.DataItem || e.Item.ItemType == ListViewItemType.InsertItem) {
    //找到链接类型的DropDownList.
    DropDownList ddListLinkType = (DropDownList) e.Item.FindControl ("ddListLinkType");
    //找到显示类型的logo地址的控件.
    TextBox FLogoURLTextBox = (TextBox) e.Item.FindControl ("FLogoURLTextBox");if (ddListLinkType != null && FLogoURLTextBox != null) {
    ddListLinkType.Attributes["onchange"] = "linkTypeChange(this,'" + FLogoURLTextBox.ClientID + "')";if (ddListLinkType.SelectedValue == "text") { //如果类型是文件,logo地址隐藏.
    FLogoURLTextBox.Style["display"] = "none"; //设置style而不是属性.
    }
    else if (ddListLinkType.SelectedValue == "pic") { //如果类型是图片,logo地址显示.
    FLogoURLTextBox.Style["display"] = "";
    }
    else {
    throw new Exception ("未知");
    }
    }
    }
    3、ListView中InsertTemplate中待隐藏的TextBox:
    <asp:DropDownList ID="ddListLinkType" ValidationGroup="edit" runat="server">
    <asp:ListItem Value="text">文本</asp:ListItem>
    <asp:ListItem Value="pic">图片</asp:ListItem>
    </asp:DropDownList><asp:TextBox ID="FLogoURLTextBox" runat="server" ValidationGroup="edit" 
    Text='<%# Bind("FLogoURL") %>' />
    4.需求:DropDownList为“文本”时,隐藏TextBox(FLogoURLTextBox).
      

  4.   

    害得我弄那么久,这你能信!这个代码是bug,被你说中了,在2008运行没有问题,在2010却是有问题!
      

  5.   

    但是我的代码是在VS写的哈,解析到浏览器的是asp引擎。
    其实这个bug也不是我发现的。是教程里面的!