帮助我在vb.net中创建链接 [英] Help me in creating a link in vb.net

查看:59
本文介绍了帮助我在vb.net中创建链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个按钮来打开诸如
之类的链接 http://www.yahoo.com/first&second

我想先从textbox1.text
获取整数 第二个是来自richtextbox1.text
的字符串
如何将两者结合在一个链接中..

例如:
如果我们在textbox1.text
中输入12345 和rakesh在textbox2.text

链接应该像
一样打开
http://www.yahoo.com/12345&rakesh

首先帮助我在vb.net

i am creating a button to open a link such as
http://www.yahoo.com/first&second

i wanna take first as integer from textbox1.text
and second as string from richtextbox1.text

how it is possible to combine both in a single link..

for example:
if we input 12345 in textbox1.text
and rakesh in textbox2.text

link should open as like

http://www.yahoo.com/12345&rakesh

help me in coding in vb.net

推荐答案

int first;
String second = String.Empty;
if(int.TryParse(textbox1.text, out first))
{
    Url myUrl = new Url(String.Format("http://www.yahoo.com/first={0}&second={1}",textbox1.Text.Trim(), HtmlEncode(richtextbox1.Text)));
}



我懒得去查一下.NET框架中隐藏的HtmlEncode功能的地方.我只是把它留给您作为练习. 注意事项:由于富文本框可能包含很多文本,因此将其放置为GET参数似乎会适得其反.您可能要考虑在POST请求中传输此参数.

干杯!

—MRB



I was to lazy to look it up where the HtmlEncode functionality is hidden in the .NET framwork. I''ll just leave that to you as an exercise. Caveat: Since a richtext box may contain quite some text, placing this as GET parameter seems counterproductive. You might want to consider transfering this parameter in a POST request.

Cheers!

—MRB


我不知道您在做什么,但是您所描述的只是简单的字符串操作.您只需要确保构建的字符串是有效的URL即可.

现在,您从未指定要使用的URL.
I have no idea what you''re doing, but what you described is simple string manipulation. You just have to make sure the string you build is a valid URL.

Now, what you do with that URL, you never specified.


您可以使用称为LinkLabel的签出 [ ^ ]有关msdn的更多信息.
You can use what is known as a LinkLabel control[^].
Also check out[^] more information on msdn.


这篇关于帮助我在vb.net中创建链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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