Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello experts,

I'm trying to create a treeview that depends on the node the end user clicks, it either launch another exe file (e.g. notepad.exe, from client side) or sending the node info back to the server (to be handled on the server side). How can I achieve this? Here's what I have tried so far:

default.aspx

...
<%@ Register src="testctrl.ascx" tagname="testctrl" tagprefix="uc2" %>
...
<html>
...
XML
<body>
    <form id="form1" runat="server">
        <table style="width: 100%;">
        <tr>
            <td>
                <uc1:myctrl ID="myctrl1" runat="server" />
            </td>
            <td>
                <uc2:testctrl ID="testctrl1" runat="server" />
            </td>
        </tr>
        </table>
    </form>
</body>


</html>

testctrl.ascx
...
XML
<asp:TreeView ID="tvwDisplay" runat="server">
    <Nodes>
    <asp:TreeNode Value="Parent1" Expanded="True" Text="Display A">
      <asp:TreeNode Value="Child1A" Text="Display A - 1" />
        <asp:TreeNode Value="Child1B" Text="Display A - 2" />
    </asp:TreeNode>
    <asp:TreeNode Value="Parent2" Text="Display B">
    </asp:TreeNode>
    <asp:TreeNode Value="Parent3" Expanded="True" Text="Display C">
      <asp:TreeNode Value="Child3A" Text="Display C - 1">
      </asp:TreeNode>
    </asp:TreeNode>
  </Nodes>
</asp:TreeView>



so from the example above, if I click Display A-1, or A-2, i want it to open an exe file with A-1 or A-2 as an argument (i.e. open notepad with the text A-1 or A-2). If I click on Display B or Display C-1, i want to send the info I click back to the server.

Thanks in advance for you help!
Posted
Comments
Richard Deeming 28-Jul-15 13:18pm    
Websites cannot launch random exe files, because that would be a serious security vulnerability.
Tommy N 28-Jul-15 13:40pm    
Thanks for your response. This website is our intranet site and we have an in house application that we need to run. Is this possible to do?
Sergey Alexandrovich Kryukov 28-Jul-15 14:12pm    
Still, it would be possible only through some abuse. It would be the best to avoid it. There are many ways to run an application, or the applications themselves can be moved to server side. Of course you can always call a client-side script (JavaScript), but the script cannot launch an application.
—SA
Richard Deeming 28-Jul-15 14:19pm    
If it's your own custom application on your own intranet site, you might be able to use a custom protocol handler:
Registering an Application to a URI Scheme[^]
Custom URL Protocol for Invoking Application[^]

You'd have to be extremely careful with the security, though.
Tommy N 28-Jul-15 17:04pm    
Can a C++/VB function execute this application using the shellexecute command, and the user control (testctrl) some how call this function?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900