Using WebBrowser Control - Hiding all the HTMLElements apart from one Div - c#

I'm using WebBrowser control to load my page. I want to hide all the html elements in the page apart from a particular div (and its children). I've the id of that particular div. How can I hide all the other elements?
Edit
I'm creating the webbrowser instance dynamically. I want to navigate to a URL and take a screen shot of the page partially (a particular div). So I want to hide all the other elements in the page and take a screenshot.

I used JQuery to hide all the elements apart from my div and its children. I referred this post for the script and called the script in the webbrowser using InvokeScript(). It worked perfectly.

Related

best control to display div element winforms C#

I am trying to display a div element in winform solution, searching for good control from the basic/devexpress controls to display div elements but I can't find any.
is there any idea how I can display the dev elements without using web browser control

Can I render html in a different control at the same time as a WebBrowser control?

I am coding a C# forms application where I am creating some html and this is being displayed in a WebBrowser control.
My question is this: Is it possible to render some of the html tags in a different object. By this I mean, I would like to extract some html and display this html somewhere other than the main WebBrowser control.
For example:
I am displaying a jQuery slider, and I am also displaying the value of the slider in a div. If possible, I would like the jQuery slider to be displayed in the WebBrowser control, but the value of the jQuery slider to be displayed in another control.
Can this be done, and if so, what concept do I need to implement?
Thanks.

asp FileUpload in content page not working due to updatepanel in master page

I have a master page where an update panel contains the main placeholder of the content pages.
Inside one of the content pages I need to disable the update panel in any way since I have a form with asp:fileupload control that is always returning null due to the update panel.
How can I overcome this issue?
Place your fileuploader and submit button in another update panel and add a post back trigger for this update panel.
On page load of content page, try to get the update panel of master page using FindControl method and then attach your file upload as a post pack trigger to it dynamically.
That may work
I've got a bad news for you.!
Have a look at this
http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx
The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside an UpdatePanel control:
TreeView and Menu controls.
Web Parts controls. For more information, see ASP.NET Web Parts Controls.
FileUpload controls when they are used to upload files as part of an asynchronous postback.
GridView and DetailsView controls when their EnableSortingAndPagingCallbacks property is set to true. The default is false.
Login, PasswordRecovery, ChangePassword, and CreateUserWizard controls
whose contents have not been converted to editable templates.
The Substitution control.
Validation controls, which includes the BaseCompareValidator, BaseValidator, CompareValidator, CustomValidator, RangeValidator, RegularExpressionValidator, RequiredFieldValidator, and ValidationSummary control.
Solution :
You may want to use Ajax FileUpload using Jquery in place of update Panel. Remember, Open source is always a better option. :)

Display web form in tooltip

I have used calendar control of ASP.NET. When I move on any date than it will be display tooltip , in which I can show my another aspx page. And in that aspx page there is gridview.
How can I display tooltip which contains aspx page.
Try this
Track one
Use a div to position your element as a tooltip.
In that div use an iframe in which you can load your aspx page.
Track two
you can use div without iframe and use jquery to pull data from server against hovered date and render that data into that div at runtime using $("#divID").html() function.
Personally I would recommend track two because here page life cycle is eliminated and data would load much faster which is required for a tooltip,
only demerit with track two is that its a little complicated because you will have to create your design at runtime using document.createElement() and other functions like that.
You could get some help from Here maybe.

How to create aspx page on runtime and place literal control?

I have an requirement where i have to display some content on iframe dynamically. Let me explain my scenario. I have a form where i have to display some html text. Earlier what i did is , i placed a literal on the form and fill it with HTML text. All worked fine but , the text alignments of the displayed html gets overriden by the page css.
So what i want now is that, instead of literal, i place an iframe. Now at page load event , i will generate a aspx dynamically and place a literal control and fill that literal control with the html text. And then will display that aspx page in the iframe.
So i would like to know the following things:
Is this a good idea to hold heavy
text , more than 20K of chars in
memory, dynamically generate aspx
page at runtime.
If any workaround to not to inherit
the page css inside the literal
displayed.
Any other approach better than my approach.
Way to implement my approach(iframe and dynamic aspx).
--- I am using ASP.NET / C# 4.0
Loads of questions...
Thanks in advance
AmRan, if this actually is a css problem, I would first try to create separate css styles for that content and use with the first solution you did. For example, wrap your dynamic content widh
<div id="dynamicContent">
tag and place
#dynamic {}
style settings inside your css file.
I don't think the Literal control has a CssClass property so you would have to use Label instead, or some other technique.
I would try to stay away from IFrame solutions if possible.
Hope this helps.

Categories

Resources