Visual Studio“在浏览器中查看"特定页面的快捷方式? [英] Visual studio 'View in Browser' shortcut to specific page?

查看:27
本文介绍了Visual Studio“在浏览器中查看"特定页面的快捷方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 Visual Studio 2008,想知道是否有办法为在浏览器中查看"创建(键盘或工具栏)快捷方式-命令,但具有特定页面来自特定(已加载)项目.

We are using Visual Studio 2008 and would like to know if there is a way to create a (keyboard or toolbar) shortcut for the 'View in Browser'-command, but with a specific page from a specific (loaded) project.

我们总是从Project-x"的Somepage.aspx"开始测试/调试我们的应用程序.我想从这个特定的项目中创建一个使用这个特定页面/文件在浏览器中查看"的快捷方式.因此,即使我目前正在另一个项目中处理另一个文件(来自同一个解决方案),它仍然可以工作......

We always start testing/debugging our app from "Somepage.aspx" from "Project-x". I would like to make a shortcut that does 'View in Browser' with this specific page/file, from this specific project. So even if I am currently working on another file in another project (from the same solution) it should still work...

有人知道这是否可行,如果可以,如何实现?

Anybody know if this is possible, and if so, how this can be achieved?

谢谢!

推荐答案

你说得对,我的第一个答案是在浏览器中打开页面但没有启动网络服务器.试试下面的宏.它使用 ViewinBrowser 命令,因此它应该按预期工作.

You are right, my first answer opens the page in browser but doesn't launch webserver. Try the following macro. It uses ViewinBrowser command so it should work as expected.

Sub OpenMyPage()
    Dim solutionExplorerHier As EnvDTE.UIHierarchy
    solutionExplorerHier = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Object
    Dim oldSelected As Object = solutionExplorerHier.SelectedItems
    solutionExplorerHier.GetItem("MySolution\MyProject\HTMLPage1.htm").Select(vsUISelectionType.vsUISelectionTypeSelect)
    DTE.ExecuteCommand("File.ViewinBrowser")

    'restore selected items
    Dim item As EnvDTE.UIHierarchyItem
    For Each item In DirectCast(oldSelected, Array)
        item.Select(vsUISelectionType.vsUISelectionTypeSelect)
    Next
End Sub    

只需更改 GetItem 方法中的路径即可.它是您在解决方案资源管理器中看到的文件的完整路径.此宏假定该文件是您的解决方案的一部分.

Just change the path in GetItem method. It is the complete path to the file you see in your Solution explorer. This macro assumes that the file is a part of your solution.

这篇关于Visual Studio“在浏览器中查看"特定页面的快捷方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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