如何在asp.net中的标签文本中获取特定单词的位置 [英] How to get the location of specific word in a label text in asp.net

查看:74
本文介绍了如何在asp.net中的标签文本中获取特定单词的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试在linklabel中提供特定单词的链接.
例如:

Hi
I am trying to give a link for specific word in a linklabel.
eg:

Linklabel linkLabel1=new Linklabel();
        linkLabel1.Text = "Hi this is an asp.net window application";
        LinkArea obj=new LinkArea(0,14);
        linkLabel1.LinkArea = obj;
        linkLabel1.LinkColor = Color.DarkRed;
        linkLabel1.LinkVisited = false;



在这里我想给一个asp.net单词的链接.如果我想给那个asp.net单词的链接,
在linkarea中,我想定义位置,即asp.net单词的起始索引.为此,
如何从标签中找到特定的单词位置.



Here i want to give a link for asp.net word.If i want to give that link for asp.net,
in linkarea i want to define the location ,ie start index of asp.net word.For that,
How to find the specific word location from the label.

推荐答案

Hello

Here is the Solution of your Problem

///*********************Try this
int ind = linkLabel1.Text.IndexOf("asp.net");
int l = "asp.net".Length;
linkLabel1.Links.Add(ind, l);
/////////////**********


这篇关于如何在asp.net中的标签文本中获取特定单词的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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