如何在Windows窗体项目中添加网页 [英] how to add web page in windows forms project

查看:122
本文介绍了如何在Windows窗体项目中添加网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好那里,,,,,,,



在我的项目中有一个窗口形式,在那个窗体上我有一个linkLabel控件.....



现在我的问题是我想在我的项目中添加一个网页......所以当我点击



LinkLabel它必须打开那个网页.....我怎么能这样做

解决方案

参考

http://msdn.microsoft.com/en -us / library / vstudio / 3s8ys666(v = vs.100).aspx [ ^ ]

http://stackoverflow.com/questions/4744184/embedding-a-web-page-in-ac-sharp-window [<一个href =http://stackoverflow.com/questions/4744184/embedding-a-web-page-in-ac-sharp-window\"target =_ blank title =新窗口> ^ ]

在Windows窗体中托管网页 [ ^ ]


您不能添加网页到Windows窗体项目 - 网页需要IIS或类似于支持他们。但是,您可以在应用程序中或通过用户浏览器打开网页。

要在您的应用程序中打开它,您需要一个带有WebBrowser [ ^ ]对它进行控制 - 然后使用链接将URL传递给控件,​​它显示网页。只需处理LinkClicked事件即可:

  private   void  myLinkLabel_LinkClicked( object  sender,LinkLabelLinkClickedEventArgs e)
{
myWebBrowser.Navigate( www.CodeProject.com);
}







通过用户浏览器打开它同样简单:处理LinkLabel的LinkClicked事件并使用:

 System.Diagnostics.Process.Start(  http://www.CodeProject.com); 


右键单击项目>添加新项> WebForm1.aspx

现在点击链接按钮,

 Reponse.Redirect(  WEbForm1.aspx); 





-KR


Hello there,,,,,,,

In my project there is one window form and on that form I have one linkLabel control.....

Now my question is that I want to add one web page into my project ......so that when I click on the

LinkLabel it must open that web page .....so how can I do it

解决方案

refer
http://msdn.microsoft.com/en-us/library/vstudio/3s8ys666(v=vs.100).aspx[^]
http://stackoverflow.com/questions/4744184/embedding-a-web-page-in-a-c-sharp-window[^]
Hosting a webpage inside a Windows Form[^]


You can't "add a web page" to a windows forms project - web pages needs IIS or similar to support them. However, you can open a web page within your application, or via the user browser.
To open it in your app, you need a form with a WebBrowser[^] control on it - you then use the link to pass the URL to the control, and it displays the web page. Just handle the LinkClicked event and:

private void myLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
    myWebBrowser.Navigate("www.CodeProject.com");
    }




To open it via the user browser is just as easy: handle the LinkClicked event for the LinkLabel and use:

System.Diagnostics.Process.Start("http://www.CodeProject.com");


Right Click on project > Add New Item > WebForm1.aspx
now on link button click,

Reponse.Redirect("WEbForm1.aspx");



-KR


这篇关于如何在Windows窗体项目中添加网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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