C# Is it possible to change HTML from the web browser? - c#

I´m wondering if it could be possible to change the HTML document text directly from the web Browser.
I´m currently working on an email client, which uses a html template for the design.
Everything seems good but I need to configure the template.
Like I said, the template is stored in a rich textbox, which is invisible.
Basically I can see the web Browser with its template, only.
Now I want to insert my custom text to the template.
Is it possible to change the htmldocumenttext directly from the webbrowser ?
Is there another way to edit the content of the template ?

You bet it's possible. Whole libraries are written around modifying the HTML after initial delivery to the browser. Start here: http://www.w3schools.com/js/js_htmldom.asp. Then maybe: https://jquery.com/

Related

Create Print Template

I have a web services application where I would like the users to be able to define print page templates with database field placeholder in my project.for this reason I
have to provide environment for design template for my users.this templates must save in database,
then for print I get data from database and put it in placeholders.I found that "XSLT" can be usefully for this issue, but a big problem is Html result for XSLT.If There is any solution please let me know.
thanks in advance
what you can do is: create a html file template, create field placeholder in it. When you need to print it, load data from database, replace the placeholder, create the html file, load it into webbrowser class (it does not have to have an UI). then print from there.
since it is html file, you can save it to database too.
it works great in one of our project which has the same requirement.

Manipulating a webpage by its source

I have googled this with a couple of differing terms and I could not find my solution. What I want to do is to manipulate a webpage by editing its source, for example removing a part from the code maybe a div or so. I know how to get the source of a webpage and know how to change the code but I have no idea how to manipulate the page instantly, by for example removing an element.
Your help would be appreciated!
If you want to manipulate client code (HTML) what you need is Ajax.
You can use JQuery javascript library to manipulate html of a page adding, editing and removing html tags, scripts, etc.
Here you can find a decent tutorial as a start point.
If you want to manipulate server code (C# codebehind) what you need is creating a web project in visual studio (ASP.NET Web Application)
EDIT: As commented by #CSharpened both solutions are not mutual exclusive. You can have an ASP.NET Web application that uses Ajax to manipulate UI. In fact lot of people does that.
I would consider using AJAX. You can use either javascript or jquery coupled with html, asp.net and C# to achieve the results you are after.
For simple editing like removing divs or collapsing menus etc simple Javascript or jquery will suffice. However changing the coding of the page requires you to use AJAX or similar.

C# Winforms WebBrowser edit html

I want to display a webpage in a WebBroswer in my winforms application. I however want to use some custom css to change how the page looks. Is it possible to attach a style sheet and edit the html page you are viewing?
You can use this web control http://www.codeproject.com/KB/miscctrl/csEXWB.aspx
and save it as a web page and load and you can show the source in another text box , once changes are made you can save to a temp file and load it. There is an option to view local file.
I don't think that kind of thing is supported.. but anyway that would be a horrible thing to do. you may end-up interfering with the CSS used by the client page.
Have you ever seen your browser override your CSS used by page and say i want to show it this way. (I know development tools like firebug,etc do it)

Adding a HTML Control IN C# in a web application

I want to add a html control in C# which will display all the text from an html page selectively with the title given in my html page
Don't forget that when you are programming in ASP.NET, you are really programming in HTML. ASP.NET controls have their effect by generating HTML, which is then sent to the browser.
This changes your question. Your question is really, "how can I use HTML to display the contents of another web site, and how can I make ASP.NET generate the HTML that I need".
You can display the contents of another site by using an iframe:
<iframe id="myOtherSite" src="other site url"/>
You can simply place that on your ASP.NET page. However, it doesn't solve your problem with the title. I expect you can do that with some JavaScript, as your main window can access the DOM of the iframe to pick up the title and put it where you want it.
You could always use a string reader to effectively 'scrape' the page content from the 3rd party site. Then use a simple regular expression check to grab the page title. You could then do with it as you want.

Home/Landing screen design for a website in asp.net

I have an web based application. The content for the Home page has been currently mentioned in the HTML code for the Home page using , and tags. To change the content anytime in future, it needs to be changed in the HTML code. :(
Is there a way that we can pick up the content from some external place and get it reflected through the website. This ways, any change if required can be made at the external location without referring to the application's code.
Please advise if there is any solution for it.
Thanks.
You can
Use a database
Include external files using Server Side Includes
Read external files and write their contents and an alternative method
Sounds like you're looking for a Content Management System (CMS), which will allow your content editors access to modify only specific blocks of a page that you specify.
There are a ton out there to do what you want, so you don't have to start from scratch. Just Google 'CMS'.
Although I haven't used it myself, DotNetNuke is a popular one these days and has a free version.

Categories

Resources