如何在客户端使用String Builder [英] How to use String Builder at client side

查看:71
本文介绍了如何在客户端使用String Builder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将解释我做了什么....我正在接受一个字符串构建器并为其创建对象

喜欢



i will explain what i did.... i'm taking a string builder and create object for that
like

StringBuilder stringbuilder=new stringBuilder();
stringbuilder.append("<table boarder='1' width='50%'><tr>");

foreach(DataColumn datacolumn in objdatatable.Columns)
{
    //some code here
}

stringbuilder.append("</tr>");

foreach(DataRow datarow in objdatatable.Rows)
{
    // some code here
}

//and finally adding this value to

form1.add.controls(new Literal {this Text=stringbuilder.ToString()});//form1 is my Form Id

//Now grid view will display to my page





但是现在我想使用java脚本显示这个网格视图而不在我的代码中写入最后一行(form1.add.controls(new Literal {this Text = stringbuilder.ToString()}) ;)



But now i want to using java script to display this grid view without writing last line in my code(form1.add.controls(new Literal {this Text=stringbuilder.ToString()});)

推荐答案

放一些东西在html中你要将结果注入



Put something in the html that you want to inject the results into

<div id="myHtml"></div>





然后使用





then use

StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("<table><tr><td>Hello</td></tr></table>");

ClientScript.RegisterStartupScript(this.GetType(), "myHtml", "document.getElementById('myHtml').innerHTML = '" + stringBuilder.ToString() + "';", true);





你所做的事情是毫无意义的,但是一个坏主意很多层次。如果你解释了你试图解决的问题,看看是否有人可能有更好的解决方案会更好。



What you're doing is quite pointless though and a bad idea on many levels. It would be better if you explained the problem you're trying to solve to see if someone might have a better solution.


没有客户端的StringBuilder这样的东西。这是一个.NET类;在ASP.NET中,.NET仅适用于服务器端。您需要学习Web的基本概念,然后学习.NET和ASP.NET。你的问题表明你没有任何线索。



如果你需要更多的帮助,你需要解释你想要达到的目标。使用StringBuilder不是目标。



-SA
There is no such thing as "StringBuilder at client side". This is a .NET class; in ASP.NET, .NET works only on server side. You need to learn the very basic ideas of the Web and then .NET and ASP.NET. Your question shows that you have no clue.

If you need more help, you need to explain what you want to achieve. Using the StringBuilder is not a goal.

—SA


这篇关于如何在客户端使用String Builder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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