Find Element IDs of HTML TextBox - c#

I'm trying to build a very basic C# Forms application that manipulates an online form. The downside is, the website is pretty old school. I'm struggling to figure out how to 'point' to the textboxes of the website.
I'm trying to use:
webBrowser1.Document.GetElementById("PanelMain")...
But getting Null errors. When looking at the HTML of the site, its a lot of Divs inside Divs... Is there a way to list the available objects / document elements I can use?
For example, use this website. https://miscm.callmis.com/. How would I write the code to access the User Name text box to populate it with whatever string I want in C#?
I hope that makes sense - Thx

You would do the following to get access to the Username textbox of the provided page:
var userTextInput = webBrowser1.Document.GetElementById("Login1_UserName");
For accessing the iframe and if it is the only IFRAME on the page, you can do the following:
var userTextInput = webBrowser1.Document.Window.Frames[0].Document.GetElementById("Login1_UserName")

Related

How can I build a link to navigate to the parent page inside of a 2sxc app using c# razor templates?

I'm building an app that lists out careers in a listing and also has a details template.
The pages in DNN are structured like this: Students (parent) > Organize (child)
I want to make a simple link in the details template (c# razor) to point back to the parent of this child page. So when I'm on Organize, make the link point back to "Students"
Looking through the 2sxc template editor, I see that I can get the parent page's ID using: #Dnn.Tab.ParentId but I'm not sure how to construct a link using that ID.
But how can I make a link to the parent page?
One simple thing you can always do is just href="/tabid/nnn" - so
Up
Based on your description, I am not sure that covers you 100% of the time, but seemed worth pointing out. :)
If you prefer a more "code" approach, use 2sxc's Link.To()...
Up
Reference

Validate one field based on other in ektron html form?

Am working on Ektron 9.I have created an ektron html form with n number of fields.
Suppose i have a radio button list(Choice Field) following a text field.My choice radio button list has
two values Yes and No and the end user select one of those values.
I need to make the following text field required if the user select Yes in the choice radio button list.If selected No no need to make the text field required.
Is there any way to achieve the same by ektron custom validation?i have tried that but when am checking the fields the choice field not listing in the the insert field part of validation tab.
Is anything wrong with me ,if not anyone suggest a solution for this?
Custom validation like you describe is not possible with standard Ektron HTML forms. Your best bet would be to create an ASPX web form to achieve what you need.
There is the possibility of creating the HTML form, displaying it on an ASPX page and then adding your own custom javascript. However this is error prone as the HTML form and JS are very closely tied together. You are better off using an ASPX web form, and not an Ektron HTML form for this.

C# simple html editor - how to search and replace content

Today i'm working on simple html editor in visual c#.
My goal is to open pure html file from local drive (Opendialog load into string or load into webbrowser completed) and allow to edit key fragments.
application should find specific divs and return the full content of that div to textbox or better to combobox (compare to combobox item and show it).
if i change the textbox (or pick up another item from combobox) application should present changes on webbrowser control.
Then i need to print this html as is seen on webbrowser control.
Last thing is to save modified hmtl overwrting original and adding comment with changes at bottom of the html file.
I want to know how to perform search&replace in this project? How to "adress" content of a div?
Better is string searching, indexof, string.replace etc. Or drown into DOM-thing (i don't know both at the moment).
How to present changes on html preview on webcontrol component? And finally overwrite a file?
Code's examples appreciated :)
Thanks in advance
You should use HtmlAgilityPack for that, it makes working with DOM a lot more easier, than parsing it yourself.
http://htmlagilitypack.codeplex.com/
For example, here is how to get all divs
var elements = hdoc.DocumentNode.Descendants("div") /.Where(.your conditions..))/;

What control should i use to display dynamic data (pictures, names etc) like an html table on asp.net?

The source of my problem is my lack of experience with asp.net. I'm trying to display my videos in database as a html like table. Much like the main page of youtube or other video sharing websites.
To give more detail, I need to display small pictures that are linked to watch.aspx that are concerned of duration, name, users, and the thumbnail of the video.
Right now I'm creating a dynamic html table on the codebehind (programmatically creating href, div, img etc.. tags), resulting unnecessary more coding, a hard way to edit the design, less flexibility.
I know there are some nice controls that are being used in asp.net like gridview etc.. But I'm not experienced to select which or how to use.
Am I doing it the right way, or should I make them user controls, or use something like gridview, datalist, datatable?
More spesific, what is the best way to create the main page or search page of youtube on asp.net?
to give you a hint; this is what I'm asking about:
You may use DataList - ASP.NET Server control and set RepeatColumns=n property to display n columns per row.
DevExpress controls are also very good .... here is the link to their asp.net controls http://www.devexpress.com/Products/NET/Controls/ASP/

asp.net textbox to html page data

Hi I'm a bit rusty with this again, I have a user profile web page and I'm working on making a wall posting system, I can do it the crappy n easiest way: textbox to listbox and then save the listbox as a text document for retrieval when the client logs in again.
But id like to write it to the HTML code or something of that nature. Like those div containers so my style sheet is applied to the data being posted.
Could anyone give me a head start to this?
You know from where you need to copy (sorry... take inspiration) your functionality.
Have a text box
User submits the data...
Add it to DB and either return the same data and add new table row below the previous one
or just on client add extra "TR" below the previous "TR".
It will require jQuery or any other similar thing. You have SO, dissect it using Firebug and build your own version of it.
You can do this with jQuery
$('button').click(function(){
var x = $('textarea').val();
$('div').html(x);
});
Check working example at http://jsfiddle.net/dzert/

Categories

Resources