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
question on web page login
Page 1 of 110 Replies - 497 Views - Last Post: 26 September 2012 - 01:44 PM
Replies To: question on web page login
#2
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.
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
#3
Re: question on web page login
Posted 26 September 2012 - 05:32 AM
rgfirefly24, 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.
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.
#4
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
#5
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
I hope this makes sense now.
Newbie = Confusion
#6
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.
#8
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.
#9
Re: question on web page login
Posted 26 September 2012 - 11:36 AM
Curtis 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?
#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:
My HTML for http://localhost
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.
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.
#11
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
Thank You Both
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|