在客户端中分配标签框的文本值。 [英] Assign Text Value of Label Box in clientside.

查看:83
本文介绍了在客户端中分配标签框的文本值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我需要在客户端分配labelbox的文本值。代码粘贴在下面。



Dear All,

I need to assign the text value of labelbox in client side.The code is pasted below.

<% For Each one_document As Object In FileRepository.GetAllDocuments()
            %>
             <tr>
                 <td>
                     <%= one_document %>
                     <asp:Label ID="Label4" runat="server" Text="<%# one_document %>"></asp:Label>
                 </td>
             </tr>

           <% Next%>





我需要在标签框中输入one_document字符串值。



请帮助



I need to get the one_document string value in the label box.

Please help

推荐答案

Seriously, this is a terrible way to code - you will never progress anywhere useful going about things this way.  This "spaghetti code" - mixing HTML with server side code - goes completely against what ASP.NET is about.

If you haven't got it, you can download free versions of Visual Studio from the Microsoft website. Learn to use it (and .NET) properly, and you'll find programming much more enjoyable and even easier too.

In your case here, you'd use a Repeater control - something like:

<pre>  <HeaderTemplate><table></HeaderTemplate>
  <ItemTemplate>
      <tr>
         <td><asp:Literal runat="server" ID="litX"></asp:Literal></td>
      </tr>
  </ItemTemplate>
  <FooterTemplate></table></FooterTemplate>





然后在后面的代码中,也许在Page_Load或按钮点击事件中,你有你的For ... Next循环





Then in the code behind, perhaps in Page_Load or a button Click event, you have your For...Next loop

For Each one_document As Object In FileRepository.GetAllDocuments()
 ...
Next





,并将您想要的值分配给某种数据源 - 可能是一个集合,也可能是DataBind到转发器。



最后,在转发器的Ite中mDataBound事件,你相应地设置litX的值。



and in that assign the values you want to some kind of datasource - a collection, maybe, and DataBind that to the repeater.

Finally, in the repeater's ItemDataBound event, you set the value of litX accordingly.


这篇关于在客户端中分配标签框的文本值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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