Submitting a form programmatically [duplicate] - c#

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do you programmatically fill in a form and 'POST' a web page?
I've been looking for a way to allow a user to submit a form using C# or even HTML,so I get the source code, save it in a file and get the name of the text fields in order to submit the form.
for example logging with ur email to Facebook, gmail,stackoverflow ... or any page containing a form.
Before I ask how,is it possible?
My project is mainly to help visually impaired people surf the web easier! like get any html source code and be able to re-arrange the tags, omit images and such tags that won't benefit them,and try to give them the ability to log in using speech to text ...so my code will take the speech convert it to text field by field and submit the form when he/she's done! of course the name of the fields will be spoken using text to speech!
Thanks in advance

Have you looked at the WebBrowser control?
http://msdn.microsoft.com/en-us/library/aa752041(v=vs.85).aspx
It will allow you to automate surfing. You'll also be able to interact with the pages and modify values in text boxes, click buttons, submit forms.
Here's some talk about how to handle clicking.
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/2eed72f7-4fde-4730-abf7-738e9b6e87c4/
I've used that approach successfully in the past, but I will say it's problematic if you don't/can't control the website. If I write a program that will automate logging into facebook with this method it would require me telling it what URL to visit, what textboxes to fill, and what form name or button name to click.
If Facebook redesigns their layout - my code may no longer work.
If you are just interested in the logging in part; you might want to take a look at browser addons (I don't know if this will help at all, but I thought I would mention it). I use a product called, 'LastPass' (https://lastpass.com/) and it manages all of my user names and passwords. If I visit a site it is familiar with, it can automatically fill in the forms for me, allowing me to log in or completely enter my address.

Related

.net Replace text with username at runtime

I am writing a C# .net website for management use within my company. On this page, I have a location on the main page to hold notices, which are contextually colored information panels. On the options page, you are given the ability to create them by filling out a form containing the notification's title, message, and a drop down for its class.
One of the the options I would like to provide for the users is to use {name} within the message to show the username of the person viewing the notification. I attempted to use message.Replace("{name}", "<asp:LoginName ID=\"LoginName1\" runat=\"server\" />");, but this resulted in that exact string being posted as opposed to the .net parser converting it into the username.
I am using the default asp.net user creation engine and database, though I've also heard that Silverlight is now the standard.
As for my questions, would I be better off rebuilding the project in Silverlight, assuming Silverlight has the capability to handle secure logins? Also, what would be the correct way to go about replacing the username? Would I be better off with something like {user=#} where # is the user's ID? Theoretically, it would just be a database query from within my Notice class (the constructor calling a method that replaces bbcode with its html counterpart).
Thank you for your help
<asp:LoginName ID=\"LoginName1\" runat=\"server\" /> will work only if directly put in the ASPX. If you want to dynamically set the name without using a control, there's two way:
From the page's code-behind, you can call this.User.Identity.Name
From anywhere in the app, you can call HttpContext.Current.User.Identity.Name

C# Winform save settings

I am working on a project in C# Winforms and one of the requirements is to allow the user to save various settings versions and give a name for each of them. The idea is to have a form, the user press the button Save Setting, enter a string in the text box for the name for that setting. Later the user can select from a comboBox which settings to use. I already created a standard setting which saves automatically when the user closes the form. Can you please direct me on how to that?
EDIT:
The following forms demonstrate what I would like to achieve.
The user enter some data in the textBoxes (form Main), then save the details giving to this setting the name of setting01 (form Save setting). Then enter some other details and give the name of setting02.
Now the user can use setting01 or setting02, which contain different values for the same textBox.
Can please someone help me with this adventure?
Microsoft Developer Network has a nice tutorial on how to create a database and using it to store and retrieve data here
Hope it helps.
EDIT:
When the data is collected, do:
combobox1.items.add(data_that_was_collected);

How can I copy HTML textbox values from one domain to another domain's textboxes?

I'm trying to help save time at work with for a lot of tedious copy/paste tasks we have.
So, we have a propitiatory CRM (with proper HTML ID's, etc for accessing elements) and I'd like to copy those vales from the CRM to textboxes on other web pages (outside of the CRM, so sites like Twitter, Facebook, Google, etc)
I'm aware browsers limit this for security and I'm open to anything, it can be a C#/C++ application, Adobe AIR, etc. We only use Firefox at work so even an extension would work. (We do have GreaseMonkey installed so if that's usable too, sweet).
So, any ideas on how to copy values from one web page to another? Ideally, I'm looking to click a button and have it auto-populate fields. If that button has to launch the web pages that need to be copied over to, that's fine.
Example: Copy customers Username from our CRM, paste it in Facebook's Username field when creating a new account.
UPDATE: To answer a user below, the HTML elements on each domain have specific HTML ID's. The data won't need to be manipulated or cleaned up, just a simple copy from ourCRM.com to facebook.com / twitter.com
Ruby Mechanize is a good bet for scraping the data. Then you can store it and post it however you please.
First, I'd suggest that you more clearly define exactly what it is you're looking to do. I read this as you're trying to take some unstructured data from Point A and copy it to Point B. Do the names of these fields remain constant every time you do the operation? Do you need to simply pull any textbox elements from the page and copy them all over? Do some sort of filtering of this data before writing it over?
Once you've got a clear idea of the requirements, if you go the C# route, I'd use something like SimpleBrowser. Judging by the example on their Github page, you could give it the URL of the page you're looking to copy, then name each of the fields you're looking to obtain the value of, perhaps store these in an IDictionary, then open a new URL and copy those values back into the page (and submit the form).
Alternatively, if you don't know the names of the fields, perhaps there's a provided function in that or a similar project that will allow you to simply enumerate all the text fields on the page and retrieve the values for all of them. Then you'd simply apply some logic of your own to filter those options down to whatever is on the destination form.
SO we thought of an easier way to do this (in case anyone else runs into this issue).
1) From our CRM, we added a "Sign up for Facebook" button
2) The button opens a new window with GET variables in the URL
3) Use a greasemonkey script to read those GET variables and fill in textbox values
4) SUCCESS!
Simple, took about 10 minutes to get working. Thanks for you suggestions.

Is it possible to encrypt the source of iframe

I have a webpage which has a iframe, textbox and button but nothing else... user types a URL to the textbox then clicks on the button. after that, URL is assined as the source of the iframe.
what happenes after is a java applet takes the screenshot of the webpage etc. etc.
What I discovered today, in Google Chrome, there is this option in the right click menu named "inspect element". With the help of this feature, user are likely to change whats inside of an iframe and manipulates the original data. Does anyone know how can I encrypt the source of iframe.
P.S. source of iframe is authenticated data.
This is what it look like before manupilation
This is after manupilation
The short answer to your question is "no". Html is a client-side SCRIPT language; while you may find ways to make things increasingly difficult to "manipulate", you ultimately have no ability to entirely prevent a user from seeing every single detail of what you are trying to do with 1 significant exception and that is the use of an applet or plugin (ie: flash, java, activex).
To help with your problem, if you are already using an applet, why not leverage that over using an iframe? You could also consider using the applet to generate a jpeg for delivery rather than HTML.

Custom phone numbers control

I have a database that stores an arbitrary number of phone numbers. There are a few pages that (should) allow admins to change these numbers and add them.
I plan to create a custom control that will:
Show all existing numbers
Provide an edit button
In Edit mode, will show an add button
Have an add button that adds the requisite fields in a way that does not cause a postback.
Provide a save button (of course)
These seems like a complicated task. I've done a bit of research, but haven't found any ready-made solutions. Is there anything I should have spotted or should know before I go about writing this from scratch?
I've built something like this using jQuery. Use a table to display the phone numbers. Then, jQuery excels at being able to hook into button presses and manipulate elements on the page (wrap a table cell's contents with an input box, or add add a table row) without causing a postback, completely aside from any server-side ASP.NET controls. Then, on Save you can stuff the phone numbers into an <input type="hidden runat="server"> in a delimited format (e.g., "212-555-1212|617-555-1212") and let the Save button do a regular postback.
You could probably find a commercial datagrid control with Ajax features to enable editing and add rows but you'd probably spend as much time customizing it as you would writing it from scratch with jQuery. It's the sort of thing you've seen dozens of places but everyone does it a little different.
I've never seen a custom control that worked specifically like that. I'd search on CodeProject to see if a custom control exists before writing one.
Are the existing numbers in a variety of formats? For example: 123-456-7890 and (123) 456 7890? If so, you may have to decide in advance on the format you are going to use and then run a script to clean up the existing records. I would use JQuery as suggested by Marc to enhance the editing experience. Validation will have to be precise.

Categories

Resources