如何在vb stringbuilder中编写此代码以进行更改? [英] How to write this code to change in vb stringbuilder?

查看:56
本文介绍了如何在vb stringbuilder中编写此代码以进行更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的java脚本代码 - :





 < script     type   =  text / javascript >  
function showhead(imagename,itm){
debugger;

document.getElementById( headicon)。className = imagename;

document.getElementById( headContent)。innerHTML = itm;
var link = document.getElementById(' accountSection');
链接。 style.display = ' none'; //或
//link.style.visibility = ' hidden';
}


< / script >

和image.aspx代码



 <   a     href   =    önclick  =  return showhead('imagename','subcategoryname'); >  <   / a  >  









我的VB字符串构建器中的代码



 私有  Sub  bindCategory()

Dim dtCategory As DataTable
Dim dtSubCategory As DataTable

< span class =code-keyword> Dim strCategoryName As String
< span class =code-keyword> Dim strCategoryImage As String
< span class =code-keyword> Dim strCategoryId As 整数
< span class =code-keyword> Dim strSubCategoryName As String
< span class =code-keyword> Dim s trSubCategoryId 作为 整数

Dim sb = StringBuilder

dtCategory = GetCategory()
For 每个作为 DataRow dtCategory.Rows
strCategoryName = row.Item( Category_Name)。ToString
strCategoryImage = row.Item( Category_ImageFilePath)。ToString
strCategoryId = row。 Item( CategoryID

sb.Append( < li>
sb.Append( < div class = responsive-accordion-head > < img src = + strCategoryImage + >< / img> <aönclick= return showhead( fa =fa-plus =responsive-accordion-plus =fa-fw => < / i > < i class = < span class =code-string> fa-minus =responsive-accordion-minus =>< div class = responsive-accordion-head >
'< span class =
fa fa-automobile >< / span><aönclick= return showhead(' fa fa-automobile','section Three');>
' id =>第三节< / a>
'

' < / div>



sb.Append( < div class = responsive-accordion-panel >
sb.Append( < div class = menu >

dtSubCategory = GetAllSubCategory(strCategoryId )

对于 每个 row1 正如 DataRow dtSubCategory.Rows
strSubCategoryName = - + row1.Item( SubCategory_Name)。ToString
' strSubCategoryId = row1.Item(CategoryID)
strSubCategoryId = row1.Item( SubCategoryID

sb.Append( < ul>
' sb.Append(< li>< a href =# önclick=return showhead(>+ strSubCategoryName +< / a>< / li>)

' < li>< a href =#önclick=return showhead('fa fa-automobile','Submenu1');> Submenu1< / a>< / li>

sb.Append( < li>< a href = önclick= return showhead( strcategoryimage = strsubcategoryname =); > + strSubCategoryName + < / a>< / li>

sb.Append( < / ul>
下一页
sb.Append( < / div>
sb.Append( < / div>
sb.Append(<温泉n class =code-string> < / a>< / div>< / li>
< span class =code-keyword> Next
ltrlCategory.Text = sb.ToString()


End Sub



但它无效javascript调用showhead()... ..



所以,请帮助我.....

解决方案

 Private Sub bindCategory()

Dim dtCategory As DataTable
Dim dtSubCategory As DataTable

Dim strCategoryName As String
Dim strCategoryImage As String
Dim strCategoryId As Integer
Dim strSubCategoryName As String
Dim strSubCategoryId As Integer

Dim sb = New StringBuilder

dtCategory = GetCategory()
For Each Row As DataRow in dtCategory.Rows
strCategoryName = row.Item(Category_Name)。ToString
strCategoryImage = row.Item(Category_ImageFilePath)。ToString
strCategoryId = row.Item(CategoryID)

sb.Append(< ; li >
sb.Append(< div class =' responsive-accordion-head' > < img src = + strCategoryImage + > < / img > &a mp; nbsp;& nbsp; < a onclick =' return showhead(' + strCategoryImage + ',' + strCategoryName + ' ); > + strCategoryName +< / a > < i class =' fa fa-plus responsive-accordion-plus fa-fw' < span class =code-keyword>> < / i > < i class =' fa fa-minus responsive-accordion-minus fa-fw' > < / i > < / div >

sb.Append(< div =' responsive-accordion-panel' >
sb.Append(< div class =' 菜单' >

dtSubCategory = GetAllSubCategory(strCategoryId)

For Each row1 As DataRow in dtSubCategory.Rows
strSubCategoryName = - + row1.Item(SubCategory_Name)。ToString
'strSubCategoryId = row1.Item(CategoryID)
strSubCategoryId = row1.Item(SubCategoryID)

sb.Append(< ul >
'sb.Append(< li > < a href = ' #' onclick =' 返回showhead(' < span class =code-attribute> + strCategoryImage + ',' + strSubCategoryName + ');' > + strSubCategoryName +< / a > < < span class =code-leadattribute> / li >

'< li > < ; a href = onclick = return showhead('fa fa-automobile','Submenu1'); > 子菜单1 < / a > < / li >

sb.Append(< li > < a href =' #' onclick = return showhead(' + strCategoryImage < span class =code-attribute> + ',' + strSubCategoryName + '); > + strSubCategoryName +< / a > < / li >

'sb.Append(< li > < a href =' #' onclick = return showhead(< img src =' + strCategoryImage +' / > ',' + strSubCategoryName +');>+ strSubCategoryName +< / a < span class =code-keyword>> < / li >

sb.Append(< / ul >
下一页
sb.Append(< / div >
sb.Append( < / div >
sb.Append(< / li >
下一个
ltrlCategory.Text = sb.ToString()


End Sub


My java script code-:


<script type="text/javascript">
    function showhead(imagename, itm) {
        debugger;

        document.getElementById("headicon").className = imagename;

        document.getElementById("headContent").innerHTML = itm;
        var link = document.getElementById('accountSection');
        link.style.display = 'none'; //or
        //link.style.visibility = 'hidden';
    }


</script>

and image.aspx code

<a href="#" önclick="return showhead('imagename','subcategoryname');"></a>





My VB Code In string builder

Private Sub bindCategory()

    Dim dtCategory As DataTable
    Dim dtSubCategory As DataTable

    Dim strCategoryName As String
    Dim strCategoryImage As String
    Dim strCategoryId As Integer
    Dim strSubCategoryName As String
    Dim strSubCategoryId As Integer

    Dim sb = New StringBuilder

    dtCategory = GetCategory()
    For Each row As DataRow In dtCategory.Rows
        strCategoryName = row.Item("Category_Name").ToString
        strCategoryImage = row.Item("Category_ImageFilePath").ToString
        strCategoryId = row.Item("CategoryID")

        sb.Append("<li>")
        sb.Append("<div class="responsive-accordion-head"><img src=" + strCategoryImage + "></img>  <a önclick="return showhead(" fa="" fa-plus="" responsive-accordion-plus="" fa-fw="></i><i class=" fa-minus="" responsive-accordion-minus=""><div class="responsive-accordion-head">
        '        <span class="fa fa-automobile"></span>  <a önclick="return showhead('fa fa-automobile','section Three');">
        '            id="">section Three </a>
        '        
        '    </div>



        sb.Append("<div class="responsive-accordion-panel">")
        sb.Append("<div class="menu">")

        dtSubCategory = GetAllSubCategory(strCategoryId)

        For Each row1 As DataRow In dtSubCategory.Rows
            strSubCategoryName = "--" + row1.Item("SubCategory_Name").ToString
            'strSubCategoryId = row1.Item("CategoryID")
            strSubCategoryId = row1.Item("SubCategoryID")

            sb.Append("<ul>")
            'sb.Append("<li><a href="#" önclick="return showhead(">" + strSubCategoryName + "</a></li>")

            '<li><a href="#" önclick="return showhead('fa fa-automobile','Submenu1');">Submenu1</a></li>

            sb.Append("<li><a href="#" önclick="return showhead(" strcategoryimage="," strsubcategoryname=");">" + strSubCategoryName + "</a></li>")

            sb.Append("</ul>")
        Next
        sb.Append("</div>")
        sb.Append("</div>")
        sb.Append("</a></div></li>")
    Next
    ltrlCategory.Text = sb.ToString()


End Sub


but it's not working javascript call showhead().....

so, please help me.....

解决方案

Private Sub bindCategory()

    Dim dtCategory As DataTable
    Dim dtSubCategory As DataTable

    Dim strCategoryName As String
    Dim strCategoryImage As String
    Dim strCategoryId As Integer
    Dim strSubCategoryName As String
    Dim strSubCategoryId As Integer

    Dim sb = New StringBuilder

    dtCategory = GetCategory()
    For Each row As DataRow In dtCategory.Rows
        strCategoryName = row.Item("Category_Name").ToString
        strCategoryImage = row.Item("Category_ImageFilePath").ToString
        strCategoryId = row.Item("CategoryID")

        sb.Append("<li>")
        sb.Append("<div class='responsive-accordion-head'><img src=" + strCategoryImage + "></img>&nbsp;&nbsp;<a onclick='return showhead('" + strCategoryImage + "','" + strCategoryName + "');>" + strCategoryName + "</a> <i class='fa fa-plus responsive-accordion-plus fa-fw'></i><i class='fa fa-minus responsive-accordion-minus fa-fw'></i></div>")

        sb.Append("<div class='responsive-accordion-panel'>")
        sb.Append("<div class='menu'>")

        dtSubCategory = GetAllSubCategory(strCategoryId)

        For Each row1 As DataRow In dtSubCategory.Rows
            strSubCategoryName = "--" + row1.Item("SubCategory_Name").ToString
            'strSubCategoryId = row1.Item("CategoryID")
            strSubCategoryId = row1.Item("SubCategoryID")

            sb.Append("<ul>")
            'sb.Append("<li><a href='#' onclick='return showhead('" + strCategoryImage + "','" + strSubCategoryName + "');'>" + strSubCategoryName + "</a></li>")

            '<li><a href="#" onclick="return showhead('fa fa-automobile','Submenu1');">Submenu1</a></li>

            sb.Append("<li><a href='#' onclick=""return showhead('" + strCategoryImage + "','" + strSubCategoryName + "');"">" + strSubCategoryName + "</a></li>")

            'sb.Append("<li><a href='#' onclick=""return showhead(<img src='" + strCategoryImage + "' />','" + strSubCategoryName + "');"">" + strSubCategoryName + "</a></li>")

            sb.Append("</ul>")
        Next
        sb.Append("</div>")
        sb.Append("</div>")
        sb.Append("</li>")
    Next
    ltrlCategory.Text = sb.ToString()


End Sub


这篇关于如何在vb stringbuilder中编写此代码以进行更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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