|
my obstacles and express language, English is not my main language
In C # it allows type declarations corresponding row and column types as follows:
Dictionary<DataRow, Color> colors = new Dictionary<DataRow, Color>();
Dictionary<DataColumn, Color> colors = new Dictionary<DataColumn, Color>();
but I want to declare the type of cell that is the type of grid, I don't found place.
Dictionary<???, Color> colors = new Dictionary<???, Color>();
|
|
|
|
|
I have no idea what you're doing because the code doesn't make any sense to me. Why would you have an entire DataRow or Column as a key in a dictionary??
|
|
|
|
|
because I do not want to use the loop (for or while) to access grid
|
|
|
|
|
Very, very weird. It's like you're trying to treat the grid like it was an Excel sheet. These data grids are not designed for that.
Individual cells do not have a data type. The type is determine by the type of the column.
|
|
|
|
|
saving keypairs , public keys to file, using these keys to encrypt decrypt a file?
|
|
|
|
|
Saving keypairs? Which keypairs?
Which type of file are you using?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thanks for your reply. I figured this out
KeyPair keyPair = PublicKeyBox.GenerateKeyPair();
byte[] privateKey = keyPair.PrivateKey;
byte[] publicKey = keyPair.PublicKey;
File.WriteAllBytes(privateFilePath, privateKey);
File.WriteAllBytes(publicFilePath, publicKey);
|
|
|
|
|
This is my first time trying to do anything more than open a webpage as a process.
I'd like to open a page in IE and then fill in a text box with the id being shown below in the small code snippet.
I think I can use WebRequest for this, but I've tried a few code samples I found online and it does not open the webpage in IE, so I'm not sure where to start to get a simple example working and build off of it.
<div class="formControl"><input name= "username" id= "txtlogin" maxlength= "75" placeholder= "Username" size= "25" type= "text" class= "" />
</div>
<html style="height: 100%;">
<HEAD>
<meta http-equiv="x-ua-compatible" content="IE=Edge"/>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Self Service Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex">
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery-ui-1.10.3.custom.min.js"></script>
</HEAD>
<BODY style="height: 100%;">
Employee Self-Service
<form method= "POST" action= "ee-loginproc.php" name= "frmEELogin" class= "" >
<label class="standard" for="username">
Username
</label>
<input name= "username" id= "txtlogin" maxlength= "75" placeholder= "Username" size= "25" type= "text" class= "" />
<label class="standard" for="userpass">
Password
</label>
<input type= "password" name= "userpass" id= "txtpass" maxlength= "40" placeholder= "Password" autocomplete= "off" size= "25" class= "" />
<label class="standard" for="userpin">
Last 4 digits of SSN
</label>
<input name= "userpin" id= "userpinid" type= "password" maxlength= "4" placeholder= "Last 4 digits of SSN" size= "25" class= "" />
<input size= "1" type= "submit" value= "Log in" name= "submit" id= "submit" class= "buttonPrimary" />
Forgot Password</form>
<script src="js/modernizr.js"></script>
<script src="../cl/js/pcm_cl_cust.js"></script>
<script>
$(document).ready(function(){
$("#txtlogin").focus();
});
</script>
</body>
</html>
|
|
|
|
|
I found an addin called Selenium that will do this, but then I have to have additional dlls to my executable and it's 5mb, which is 10 times my exe's size and way overkill.
No one has ever opened a page and then posted data to the input id's?
|
|
|
|
|
turbosupramk3 wrote: No one has ever opened a page and then posted data to the input id's? Google will show quite some hits.
If you want to manipulate IE, you will have to launch IE and manipulate that.
If you want to fill in values in a webpage, you use a WebBrowser control.
If you want to submit the data without any browser, use the WebRequest.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi, thanks for the response.
I've been trying with webbrowser for the past hour or so. Depending on my code that I'm using, it will read the page and set the value, but not open the page with the set value. Or it will open the page but not set the value. I'm missing something that allows the two to work in harmony. Can you tell what I'm doing wrong?
I believe I need to open the page, download the source, update the elements and reopen it in my browser, is this correct?
I started with this: http://stackoverflow.com/questions/8425593/c-sharp-httpwebrequest-post-login-to-facebook/15772387#15772387[^]
string email = "firstlast@gmail.com";
string password = "12345678";
string url = @"https://www.url.net/v4/ee/ee-login.php";
WebBrowser webbrowser1 = new WebBrowser();
webbrowser1.Navigate(url);
Application.DoEvents();
webbrowser1.Document.GetElementById("txtlogin").SetAttribute("value", email);
|
|
|
|
|
turbosupramk3 wrote: Can you tell what I'm doing wrong? Using "DoEvents"; it is almost always a hint that there is something wrong.
The "Navigate" method is not blocking, and DoEvents will return before the page is completely loaded. You want to wait with setting values until the document completes loading[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'm trying but I can't get it, I feel like this is going to have to be spoon fed to me or I'm not going to get it?
I've been trying an event based method (link to code below) as well. Stepping through the code, I can either get it to accept my element data and not open the page, or not accept my element data and open the default page, never can I get it to do both.
Is the order of operations to load the page first and then submit the data, or do I need to ingest the data, update the elements and then load the page from the modified version?
http://www.dreamincode.net/forums/topic/152297-c%23-log-in-to-website-programmatically/page__view__findpost__p__1229505[^]
|
|
|
|
|
Like this?
private void editPage(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.GetElementById("txtlogin").SetAttribute("value", "my login");
webBrowser1.Document.GetElementById("txtpass").SetAttribute("value", "my password");
}
private void btnTestCalculate_Click(object sender, EventArgs e)
{
string email = "firstlast@gmail.com";
string password = "12345678";
string url = @"https://www.url.net/v4/ee/ee-login.php";
webBrowser1 = new WebBrowser();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(editPage);
webBrowser1.Navigate(url, true);
}
|
|
|
|
|
Looks correct; open a browser, load a document, wait until loaded, adapt it's contents.
Any redirections should be handled by the Webbrowser control. Do take in account that if you submit the page (ie, press login in the UI after this code runs) then it will navigate to another page, and the "document completed" event (or editpage) will be called again.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
For whatever reason that code sample does not work.
|
|
|
|
|
Does it throw an exception or does it do something different than expected?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
All it does is open the webpage.
I put a break point at the
webBrowser1.Document.GetElementById("txtlogin").SetAttribute("value", "my login");
and it never catches the event.
I then created a second document completed event as seen below and it isn't catching that either?
webBrowser1 = new WebBrowser();
webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
webBrowser1.Navigate(url, true);
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
MessageBox.Show("Here");
}
|
|
|
|
|
Ok, I figured out why the event doesn't fire. If I put
webBrowser1.Navigate(url); it will fire, but if I put
webBrowser1.Navigate(url, true); it will not fire. The problem with that is if I use just
webBrowser1.Navigate(url); then the browser does not open and nothing occurs visibly? Any ideas?
|
|
|
|
|
Yes; add the webbrowser-control to your form and it will simply work. If the url is navigated to in an external browser, then it is no longer part of your application and will not receive any events.
Below code should work and show the basic idea;
class Program
{
static WebBrowser _wb;
[STAThread()]
static void Main(string[] args)
{
using (Form f = new Form())
{
_wb = new WebBrowser() { Dock = DockStyle.Fill };
f.Controls.Add(_wb);
_wb.Navigate(@"http://www.gmail.com");
_wb.DocumentCompleted += wb_DocumentCompleted;
f.ShowDialog();
}
}
static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
_wb.Document.GetElementById("Email").SetAttribute("value", "s.jobs@msdn.com");
}
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you, this did work as far as logging me in. This is similar to something I had working yesterday with one of my attempts, it used a mshtml reference I believe.
What steered me away from this yesterday is that it is the webbrowser control and not IE. I have to create a browser helper and not a stand alone browser.
Is there any way to load the page into memory, login and then spawn the logged in page in IE and at that point disconnecting it from any application control? Am I trying to do something that cannot be done?
|
|
|
|
|
turbosupramk3 wrote: I have to create a browser helper and not a stand alone browser.
Well, that is a different story then. Google for "Browser Helper Object", and try some of those examples.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The easiest way would be to use Selenium WebDriver.If you are using Visual Studio you could add it via Nuget Package Manager.
Though its generally used for other purposes you can surely (ab)use it
|
|
|
|
|
Thanks. I tried the Selenium web driver and didn't want to have an extra 5mb (or two) dll packaged in with my executable if I didn't have to. It did work however I was hoping to use the small portion of code they use to do that, within my own project and within the .net framework instead. If the driver can do it, I can do it natively. The question is how?
|
|
|
|
|
I'm working on some client that collects information from testing station and inserts it to DB. Now i'm building a setup and i'm placing near the setup.msi some client.exe.config file with modified configurations. So the question is - is it possible somehow replace/update app.config file from external configuration file during the installation.
Thanks in advance.
|
|
|
|