473,382 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

AnuSumesh
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.Configuration;
using System.Collections;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class admin_Maintenance_rdptry : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

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

HtmlGenericControl div = new HtmlGenericControl("div");
div.ID = "connectArea";
HtmlGenericControl center = new HtmlGenericControl("center");
div.Controls.Add(center);

// Connect button for testing
/* HtmlInputButton rdpButton = new HtmlInputButton();
rdpButton.Attributes.Add("type", "button");
rdpButton.Attributes.Add("id", "btnConnect");
rdpButton.Attributes.Add("name", "ConnectButton");
rdpButton.Attributes.Add("value", "Connect");
rdpButton.Attributes["runat"] = "server";
rdpButton.Attributes.Add("onclick", "return RdpConnect()");
Page.Controls.Add(rdpButton);*/

// MsRdpClient ActiveX object
HtmlGenericControl rdp = new HtmlGenericControl("object");
rdp.Attributes["id"] = "MsRdpClient";
rdp.Attributes["name"] = "MsRdpClient";
rdp.Attributes.Add("classid","clsid:7584c670-2274-4efb-b00b-d6aaba6d3850");
rdp.Attributes["codebase"] = "msrdp.cab#version=5,2,3790,1830";
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.Add(p);



// rdpConnect
StringBuilder rdpConnect = new StringBuilder();
rdpConnect.Append("function RdpConnect()");
rdpConnect.Append("{");
rdpConnect.AppendFormat("MsRdpClient.Server=\"" + ServerName + "\";");
rdpConnect.AppendFormat("MsRdpClient.Domain=\"" + Domain + "\";");
rdpConnect.AppendFormat("MsRdpClient.UserName=\"" + UserName + "\";");
rdpConnect.AppendFormat("MsRdpClient.AdvancedSetti ngs2.ClearTextpassword=\"" + Password + "\";");
rdpConnect.Append("MsRdpClient.FullScreen=0;");
rdpConnect.Append("MsRdpClient.Width=\"" + reswidth + "\";");
rdpConnect.Append("MsRdpClient.Height=\"" + resheight + "\";");
rdpConnect.Append("MsRdpClient.DesktopWidth=\"" + reswidth + "\";");
rdpConnect.Append("MsRdpClient.DesktopHeight=\"" + resheight + "\";");
rdpConnect.Append("MsRdpClient.AdvancedSettings2.R edirectDrives=0;");
rdpConnect.Append("MsRdpClient.AdvancedSettings2.R edirectPrinters=1;");
rdpConnect.Append("MsRdpClient.AdvancedSettings2.R edirectPorts=0;");
rdpConnect.Append("MsRdpClient.AdvancedSettings2.R edirectSmartCards=0;");
rdpConnect.Append("if (MsRdpClient.SecuredSettingsEnabled)");
rdpConnect.Append("{");
rdpConnect.Append("MsRdpClient.SecuredSettings.Sta rtProgram=\"notepad.exe\";");
rdpConnect.Append("}");
rdpConnect.AppendFormat("MsRdpClient.FullScreenTit le=\"" + ServerName + "\";");
rdpConnect.Append("MsRdpClient.OnDisconnected=MsRd pClient_OnDisconnected();");
rdpConnect.Append("MsRdpClient.Onconnected=MsRdpCl ient_Onconnected();");
rdpConnect.Append("MsRdpClient.Connect()");
rdpConnect.Append("}");

//anu
// MsRdp_onConnected
StringBuilder connected = new StringBuilder();
connected.Append("Function MsRdpClient_OnConnected()");
connected.Append("{");
connected.AppendFormat("Window.Navigate(\"items.as px?nid=Maintenance\");");
connected.AppendFormat("return true;");
connected.Append("}");
// Insert the javascript function
HtmlGenericControl connectFunction = new HtmlGenericControl("script");
connectFunction.Attributes.Add("type", "text/javacript");
connectFunction.Attributes.Add("language", "javascript");
connectFunction.Attributes["runat"] = "server";
connectFunction.InnerHtml = connected.ToString();


// MsRdp_onDisConnected
StringBuilder disconnected = new StringBuilder();
disconnected.Append("Function MsRdpClient_OnDisconnected()");
disconnected.Append("{");
disconnected.AppendFormat("history.go(-1)");
//disconnected.AppendFormat("Window.Navigate(\"items .aspx?nid=Maintenance\");");
disconnected.AppendFormat("return true;");
disconnected.Append("}");
// Insert the javascript function
HtmlGenericControl disconnectFunction = new HtmlGenericControl("script");
disconnectFunction.Attributes.Add("type", "text/javacript");
disconnectFunction.Attributes.Add("language", "javascript");
disconnectFunction.Attributes["runat"] = "server";
disconnectFunction.InnerHtml = disconnected.ToString();
Page.Controls.Add(disconnectFunction);

//here

// Insert the javascript function
HtmlGenericControl rdpFunctions = new HtmlGenericControl("script");
rdpFunctions.Attributes.Add("type", "text/javascript");
rdpFunctions.Attributes.Add("language", "javascript");
rdpFunctions.Attributes["runat"] = "server";
rdpFunctions.InnerHtml = rdpConnect.ToString();
Page.Controls.Add(rdpFunctions);

// call the Javascript function RdpConnect() here
LiteralControl rdpconnect = new LiteralControl("<script type='text/javascript'>RdpConnect();</script>");
Page.Controls.Add(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]
Feb 29 '08 #1
0 4888

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: BigSizeXXL | last post by:
hi, i'm new to python and have a couple of questions about working with smtp. i read that you need a pop3 service for receiving mails. i want to create my own (private) mail service. i'm using a...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
2
by: Bill Struve | last post by:
Need: Auto-logon to a terminal server, start a program, and, when the user is quits the program, auto-logoff. Problem: When msrdp.ocx is added to the Toolbox, attempting to draw the control on...
3
by: Phil Lee | last post by:
Hi, I have a few questions regarding web services in .NET 2 1) Why, when I run code analysis do I get a source controlled files named {guid}/codeanalysislog.xml...
19
by: MP | last post by:
I'm interested to learn how to use mdb files via ado/adox via vb6 Since I'm not using Access are those types of questions o.t. here? I see very few ado questions here. But there's a lot more...
4
by: Steve | last post by:
I have read a couple articles online, read my Jesse Liberty book but I am still confused as to just what the best practices are for using exceptions. I keep changing how I'm working with them and...
0
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
0
by: mercury529 | last post by:
Hello everyone. Currently the only version of Visual Studio I own is VS6. I have developed a Web Service using VC++ 6 and the Soap Toolkit 3 Microsoft deployed prior to the .NET Web Service...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've got a .Net client to a soap service that works for the most part, but there are a couple of things I'd like to improve: 1) the first request to the client wrapper always takes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.