questions about using msrdp.cab in c# for RDP service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AnuSumesh
    New Member
    • Aug 2007
    • 96

    questions about using msrdp.cab in c# for RDP service

    Hi All,


    I want to call RDP on Page load and it is working fine.My code is in C#.
    But I am unable to perform following functions

    1. when i disconnected from RDP, i want to go back to previous page

    2. If RDP is opened in fullscreen mode, then onconnected, i want to go back to previous page.

    3. I am using master page and using footer also. When RDP opens as embedded means within same window, then it overlaps the footer.

    I have written the code for onconnected and ondisconnected. but its not working.

    My code is as follows:

    using System;
    using System.Data;
    using System.Configur ation;
    using System.Collecti ons;
    using System.Text;
    using System.Web;
    using System.Web.Secu rity;
    using System.Web.UI;
    using System.Web.UI.W ebControls;
    using System.Web.UI.W ebControls.WebP arts;
    using System.Web.UI.H tmlControls;
    public partial class admin_Maintenan ce_rdptry : System.Web.UI.P age
    {
    protected void Page_Load(objec t sender, EventArgs e)
    {

    string ServerName = "server";
    string Domain = "";
    string UserName = "anu";
    string Password = "pwd";
    string reswidth = "640";
    string resheight = "480";

    HtmlGenericCont rol div = new HtmlGenericCont rol("div");
    div.ID = "connectAre a";
    HtmlGenericCont rol center = new HtmlGenericCont rol("center");
    div.Controls.Ad d(center);

    // Connect button for testing
    /* HtmlInputButton rdpButton = new HtmlInputButton ();
    rdpButton.Attri butes.Add("type ", "button");
    rdpButton.Attri butes.Add("id", "btnConnect ");
    rdpButton.Attri butes.Add("name ", "ConnectButton" );
    rdpButton.Attri butes.Add("valu e", "Connect");
    rdpButton.Attri butes["runat"] = "server";
    rdpButton.Attri butes.Add("oncl ick", "return RdpConnect()");
    Page.Controls.A dd(rdpButton);*/

    // MsRdpClient ActiveX object
    HtmlGenericCont rol rdp = new HtmlGenericCont rol("object");
    rdp.Attributes["id"] = "MsRdpClien t";
    rdp.Attributes["name"] = "MsRdpClien t";
    rdp.Attributes. Add("classid"," clsid:7584c670-2274-4efb-b00b-d6aaba6d3850");
    rdp.Attributes["codebase"] = "msrdp.cab#vers ion=5,2,3790,18 30";
    rdp.Attributes["runat"] = "server";
    rdp.Attributes["width"] = reswidth;
    rdp.Attributes["height"] = resheight;
    center.Controls .Add(rdp);

    Panel p = new Panel();
    p.ID = "Panel1";
    p.ScrollBars = ScrollBars.Both ;
    p.Wrap = true;
    p.Height = Unit.Percentage (60);
    p.Width = Unit.Percentage (100);
    p.Controls.Add( div);
    Page.Controls.A dd(p);



    // rdpConnect
    StringBuilder rdpConnect = new StringBuilder() ;
    rdpConnect.Appe nd("function RdpConnect()");
    rdpConnect.Appe nd("{");
    rdpConnect.Appe ndFormat("MsRdp Client.Server=\ "" + ServerName + "\";");
    rdpConnect.Appe ndFormat("MsRdp Client.Domain=\ "" + Domain + "\";");
    rdpConnect.Appe ndFormat("MsRdp Client.UserName =\"" + UserName + "\";");
    rdpConnect.Appe ndFormat("MsRdp Client.Advanced Settings2.Clear Textpassword=\" " + Password + "\";");
    rdpConnect.Appe nd("MsRdpClient .FullScreen=0;" );
    rdpConnect.Appe nd("MsRdpClient .Width=\"" + reswidth + "\";");
    rdpConnect.Appe nd("MsRdpClient .Height=\"" + resheight + "\";");
    rdpConnect.Appe nd("MsRdpClient .DesktopWidth=\ "" + reswidth + "\";");
    rdpConnect.Appe nd("MsRdpClient .DesktopHeight= \"" + resheight + "\";");
    rdpConnect.Appe nd("MsRdpClient .AdvancedSettin gs2.RedirectDri ves=0;");
    rdpConnect.Appe nd("MsRdpClient .AdvancedSettin gs2.RedirectPri nters=1;");
    rdpConnect.Appe nd("MsRdpClient .AdvancedSettin gs2.RedirectPor ts=0;");
    rdpConnect.Appe nd("MsRdpClient .AdvancedSettin gs2.RedirectSma rtCards=0;");
    rdpConnect.Appe nd("if (MsRdpClient.Se curedSettingsEn abled)");
    rdpConnect.Appe nd("{");
    rdpConnect.Appe nd("MsRdpClient .SecuredSetting s.StartProgram= \"notepad.exe\" ;");
    rdpConnect.Appe nd("}");
    rdpConnect.Appe ndFormat("MsRdp Client.FullScre enTitle=\"" + ServerName + "\";");
    rdpConnect.Appe nd("MsRdpClient .OnDisconnected =MsRdpClient_On Disconnected(); ");
    rdpConnect.Appe nd("MsRdpClient .Onconnected=Ms RdpClient_Oncon nected();");
    rdpConnect.Appe nd("MsRdpClient .Connect()");
    rdpConnect.Appe nd("}");

    //anu
    // MsRdp_onConnect ed
    StringBuilder connected = new StringBuilder() ;
    connected.Appen d("Function MsRdpClient_OnC onnected()");
    connected.Appen d("{");
    connected.Appen dFormat("Window .Navigate(\"ite ms.aspx?nid=Mai ntenance\");");
    connected.Appen dFormat("return true;");
    connected.Appen d("}");
    // Insert the javascript function
    HtmlGenericCont rol connectFunction = new HtmlGenericCont rol("script");
    connectFunction .Attributes.Add ("type", "text/javacript");
    connectFunction .Attributes.Add ("language", "javascript ");
    connectFunction .Attributes["runat"] = "server";
    connectFunction .InnerHtml = connected.ToStr ing();


    // MsRdp_onDisConn ected
    StringBuilder disconnected = new StringBuilder() ;
    disconnected.Ap pend("Function MsRdpClient_OnD isconnected()") ;
    disconnected.Ap pend("{");
    disconnected.Ap pendFormat("his tory.go(-1)");
    //disconnected.Ap pendFormat("Win dow.Navigate(\" items.aspx?nid= Maintenance\"); ");
    disconnected.Ap pendFormat("ret urn true;");
    disconnected.Ap pend("}");
    // Insert the javascript function
    HtmlGenericCont rol disconnectFunct ion = new HtmlGenericCont rol("script");
    disconnectFunct ion.Attributes. Add("type", "text/javacript");
    disconnectFunct ion.Attributes. Add("language", "javascript ");
    disconnectFunct ion.Attributes["runat"] = "server";
    disconnectFunct ion.InnerHtml = disconnected.To String();
    Page.Controls.A dd(disconnectFu nction);

    //here

    // Insert the javascript function
    HtmlGenericCont rol rdpFunctions = new HtmlGenericCont rol("script");
    rdpFunctions.At tributes.Add("t ype", "text/javascript");
    rdpFunctions.At tributes.Add("l anguage", "javascript ");
    rdpFunctions.At tributes["runat"] = "server";
    rdpFunctions.In nerHtml = rdpConnect.ToSt ring();
    Page.Controls.A dd(rdpFunctions );

    // call the Javascript function RdpConnect() here
    LiteralControl rdpconnect = new LiteralControl( "<script type='text/javascript'>Rdp Connect();</script>");
    Page.Controls.A dd(rdpconnect);
    //p.Controls.Add( rdpconnect);

    }
    }

    Can anyone help me in this regard?
    Plz provide me code for occonnected and onDisconnected functions.

    Thanks in advance.
    Anu


    [/size]
Working...