10 Replies - 638 Views - Last Post: 26 September 2012 - 01:44 PM Rate Topic: -----

#1 Hankisanerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 26-September 12

question on web page login

Posted 26 September 2012 - 05:21 AM

I am trying to hard code in a username and password in a web address on a login page. It is an .asp page i.e. "http://site.com/signon.asp" Username = 1234 Password = DOG

This is driving me nuts.

I am really new so please bare with me.

TY
Is This A Good Question/Topic? 0
  • +

Replies To: question on web page login

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 262
  • View blog
  • Posts: 1,460
  • Joined: 07-April 08

Re: question on web page login

Posted 26 September 2012 - 05:26 AM

if you want to pass variables to a webpage you use what is called a Query String. The basic syntax is like so:

somesite.com/thispage.asp?variable1=foo&variable2=man&variable3=chu

Then in the thispage.asp code you would call Request.QueryString["variable1"] to get the value foo and so on.

This post has been edited by rgfirefly24: 26 September 2012 - 05:27 AM

Was This Post Helpful? 1
  • +
  • -

#3 Hankisanerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 26-September 12

Re: question on web page login

Posted 26 September 2012 - 05:32 AM

View Postrgfirefly24, on 26 September 2012 - 07:26 AM, said:

if you want to pass variables to a webpage you use what is called a Query String. The basic syntax is like so:

somesite.com/thispage.asp?variable1=foo&variable2=man&variable3=chu

Then in the thispage.asp code you would call Request.QueryString["variable1"] to get the value foo and so on.



I am not coding the page, I am coding a browser to go to an existing page.
Was This Post Helpful? 0
  • +
  • -

#4 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 262
  • View blog
  • Posts: 1,460
  • Joined: 07-April 08

Re: question on web page login

Posted 26 September 2012 - 05:38 AM

I guess my first question then is what are you trying to accomplish exactly? What is this site you are trying to "hard code" a username/password for?

This post has been edited by rgfirefly24: 26 September 2012 - 05:39 AM

Was This Post Helpful? 0
  • +
  • -

#5 Hankisanerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 26-September 12

Re: question on web page login

Posted 26 September 2012 - 06:02 AM

A long story to the short one. In C# I made a windows form and dropped in a WebBrowser. In "webBrowser1.Url" I have the URL for a web page that our customer gets access to there account history. I starts at a sign on page then goes to account history. I want to customize each one for each new customer, some of them are not the best with computers. I don't have any relationship with the "website". I do see the elements for the login, i.e. value name="cust_login" and value name="passwd_login"

I hope this makes sense now.

Newbie = Confusion
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4431
  • View blog
  • Posts: 7,702
  • Joined: 08-June 10

Re: question on web page login

Posted 26 September 2012 - 07:44 AM

You're going to have a hard time doing this with the WebBrowser control. You will probably have to load the page, find the textboxes you need, fill them using code, and then fake a click on the login button.
Was This Post Helpful? 0
  • +
  • -

#7 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 262
  • View blog
  • Posts: 1,460
  • Joined: 07-April 08

Re: question on web page login

Posted 26 September 2012 - 07:54 AM

At my last company we used AutoIt for this exact type of thing. As long as the names are known for the textboxes and the button AutoIt will be able to input data into them and even fire a click event
Was This Post Helpful? 0
  • +
  • -

#8 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4431
  • View blog
  • Posts: 7,702
  • Joined: 08-June 10

Re: question on web page login

Posted 26 September 2012 - 08:05 AM

Yeah, but I think this isn't for an external web browser. It's for the WebBrowser control in a C# program. There's no reason he can't do this all in C# code, since you have access to the DOM of the browser's document.
Was This Post Helpful? 0
  • +
  • -

#9 Hankisanerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 26-September 12

Re: question on web page login

Posted 26 September 2012 - 11:36 AM

View PostCurtis Rutland, on 26 September 2012 - 10:05 AM, said:

Yeah, but I think this isn't for an external web browser. It's for the WebBrowser control in a C# program. There's no reason he can't do this all in C# code, since you have access to the DOM of the browser's document.


You are correct, it is for the WebBrowser control in a C# program. DOM?
Was This Post Helpful? 0
  • +
  • -

#10 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4431
  • View blog
  • Posts: 7,702
  • Joined: 08-June 10

Re: question on web page login

Posted 26 September 2012 - 12:04 PM

Document Object Model.

What I mean is that you have access to the document's elements in your code.

Here's a very simple example of what I'm talking about. You'll have to do a few things differently, like doing this on DocumentComplete, and checking the URL to make sure you're not trying this on every page, but here's the general idea of how to modify a textbox and fake a button click:

C# Code:
private const string FirstName = "Curtis";

public Form1()
{
    InitializeComponent();
    Load += FormLoad;
}

private void FormLoad(object sender, EventArgs e)
{
    webBrowser1.Navigate("http://localhost/");
}

private void UpdateTextBox()
{
    var fnameTextBox = webBrowser1.document.GetElementById("txtFname");
    fnameTextBox.SetAttribute("value", FirstName);
}

private void ClickButton()
{
    var button = webBrowser1.document.GetElementById("btnSubmit");
    button.InvokeMember("click");
}

private void UpdateTextBoxClick(object sender, EventArgs e)
{
    UpdateTextBox();
}

private void ClickButtonclick(object sender, EventArgs e)
{
    ClickButton();
}



My HTML for http://localhost
<!DOCTYPE html>
<html>
    <head>
        <title>Howdy</title>
    </head>
    <body>
		First Name: <input type="text" id="txtFname" />
		<p />
		<input type="button" value="login" id="btnSubmit" />
		
		<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
		<script>
			$(document).on("ready", function(){
				$("#btnSubmit").on("click", function(){
					var val = $("#txtFname").val();
					window.location.href = "test2.html?fname=" + val;
				});
			});
		</script>
    </body>
</html>



You can see the code for finding elements is simple, just use their ID. Then you can change their values or invoke their JS members quite easily. In fact, if I run this code all in the DocumentCompleted event, it all happens too fast for you to see. That's why I broke it out into two different sections. One form button click will add text to the textbox, another will click the submit button. Of course, there's no need to actually separate them. You could have it happen as soon as the page finished loading by using the DocumentCompleted event.
Was This Post Helpful? 2
  • +
  • -

#11 Hankisanerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 26-September 12

Re: question on web page login

Posted 26 September 2012 - 01:44 PM

I am sure this will help me, but I first have to become better with my C# than I already am. (<1yr XP with C#). I do thank you very much for your time and I know I will spend many hours going though the site.

Thank You Both :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1