Microsoft Access - Web Browser ActiveX Control - Only show one DIV - css

Ok, I have an ActiveX web browser control on an Access form.
I am loading a url into this control using the following code:
Dim webMain As Object
Set webMain = Me.WebBrowser2.Object
webMain.Navigate "http://stackoverflow.com"
However, this page has multiple DIV's and I only want to show one.
Thanks
John

From your comment
I am only interested in one div in my form, as the other two are
menu's which they don't need to use or see. They just need to fill in
the form located within the main div and hit submit.
Well why bother with displaying HTML to them at all. Just collect the data on your Access form with Unbounded controls and POST the HTTP form yourself using MSXML2.ServerXMLHTTP or WinHttp.WinHttpRequest.5.1
For a sample see How can I send an HTTP POST request to a server from Excel using VBA?

Related

Possible to only update part of page and change query string parameters at same time in asp.net?

Is there a way to only update part of the page and update the query string parameters at the same time without completely refreshing the whole page in ASP.NET?
I only need to update the "main" section of my page and not the whole page. I understand I can do a partial page postback (or use asp ajax) to do the partial page update, but then how do I update the query string parameters in the URL at the same time? Is that even possible?
Or is it not possible and I'll have to just do a Response.Redirect in the code behind of the partial page postback redirecting to the same page with new query params and just let the whole page refresh?
Use pushState.
This new feature offers you a way to change the URL displayed in the browser* through javascript without reloading the page. It will also create a back-button event and you even have a state object you can interact with.
window.history.pushState(“object or string”, “Title”, “/new-url”);
Described here
You have absolutely zero programmatic access to the address bar. The only way to change it is to redirect.
You could, however, do it like some sites do and provide a "send a link to this page to your friends" area. Youtube comes to mind - see how it provides a URL, querystring parameters included, for you to copy, should you wish to send someone a link to a video starting from some specific point.
Also check the handy "Share" link right under your question. You could provide a link like that, with the target URL, so for the user it's just a matter of right-clicking and copying from the context menu. A link well structured into your site is more user friendly than having the user copy directly from the bar, or from a text box. Specially for mobile browsers, where the sequence is usually press-and-hold, then copy. Copying from the address bar, on the other hand, may involve selecting the address bar text, which in some Android devices is a pain in the ass.

how to hide complete URL in browser address bar

I want to hide the sub directory and page information from my asp.net website URL. For example instead of displaying http://msdn.microsoft.com/en-us/library/aa479015.aspx I want to display something like http://msdn.microsoft.com/ always in user's browser address bar.
This requires a modern browser with History API support
history.pushState({}, false, "/");
If you call that on document load, you should achieve the desired effect
More information:
Manipulating the browser history | MDN
One way is to save your current handler information in a cookie, then in your global asax BeginRequest, and use HttpContext.Current.RemapHandler to remap their request to a different handler based on that cookie. Another way is to make use of an iframe on your page, this would be the easiest.
Although I don't think this is good style you can insert your pages into a frame (or iframe):
Start page of your domain, f.e. http://msdn.microsoft.com/:
<frameset rows="100%">
<frame src="/realstartpage.htm">
</frameset>
Now when the user navigates to another page, the address bar will not change because only the content of the frame is updated. Be aware that links to pages outside of your website should target the outermost frame:
Stackoverflow
But when a user comes in via a direct link to http://msdn.microsoft.com/en-us/library/aa479015.aspx then you would be required to forward to http://msdn.microsoft.com/ by a script and create the frameset (or iframe) f.e. by handling an URL parameter on the server.

How does Asp.net Knows which Page to Generate?

When a client is on page A.aspx , and he press some button there is a postback.
The server knows which page to rebuild according to the request.
but how does the client knows which page to re-ask ? by the current url of his browser ?
where this information is saved in the client side ?
Its defined in the action property of <form>. The client does not need to re-ask, the server sends a response of his request.
ASP.NET is just a part of the .NET framework, but what every client sees on a web browser in plain old HTML.
ASP.NET gives you several controls that makes it easy to use them programatically, so we can set all sort of things in our code (that is run before the page is showing) to do the exactly what we want.
every link, button, image, grid, it's just HTML tags, like <a> for links, <input type="button"> for buttons etc...
Keep in mind that now, there are 2 variantes of the ASP.NET, the WebForms and the MVC (you can also read about choosing one in prole of the other)
in every ASP.NET WebForms there is always a <form> on the start of the <body> and wrapps all your code, so, any submit will do a PostBack into the same file name, in your example A.apsx will always post into A.aspx, then if you want, for example, send that request to B.aspx you need to have a Click Event that would use the Server.Transfer("B.aspx") and that would redirect the entire post to B.aspx just like it was a post from B.aspx
in the newest pattern, the ASP.NET MVC, it drives with Routes witch let's you set up any, every, one, multiple, ways to reach the same page. In MVC the URL does not point to a specific page, but to a specific Controller and it's up to the Controller to send, after processing the data, to a specific View, that is why in MVC there are no pages in the url (though you can add it to the route if you want, and you can accomplish the same with WebForms using a Routing plugin).
Now, in MVC it's there is no <form> wrapping up your entire code, you need to, if you want to submit something, create your own <form> and point to the correct route
but, just like in Webforms or any HTML page, posts are made through form submittion, and it's "path" it's always whats in the form attribute action that let's you know what's the next step.
I hope this helps you realizing that there is no big monster in ASP.NET, that is only a way to reuse controls and access them programmatically and that, in the end, it's all HTML :)
A general answer: on the client side it's either a submit from within a form or a link.
The form points to either a relative URL (that means the current URL plays a key role) or an absolute URL (the current URL plays little to no role).
For links it's generally the same: either they are relative or absolute. One big difference: links are use HTTP GET while forms can use HTTP POST (thus transferring more data without encoding them to the URL as parameters).
For a button it's the form that gets submitted.

ASP.Net Page abstraction

We have a win application that shows a web form in a web browser.
In order to get data from this web form we are using a hidden text box and get its text using HtmlDocument object of web browser control.
I want to make an abstraction of this web form that has this text box element so that other forms can use this abstraction.
I made a web control and put the text box on it.I thought that if I put this control on my page it would have the text box.When i ran my application I noticed that the text box had been rendered but had its control name in its name (WebControl$TextBoxName) and its id(WebControl_TextBoxName) and the win app throw an exception since it couldn't find the element by its id(TextBoxName).
So here's my question:
How can I make an abstract web form/web control that has some elements on it and I can use it to make my final forms have these elements on them? (their names and ids should not be changed)
Thank you for your help
dotNet 4.0 supports static id's so they don't get mangled, read up on Client Id Mode
Alternatively, you could override the render of your control to output a standard html hidden form field with whatever ID you want, and then also add a custom property that will return the textbox that will hide the fact that it isn't an asp.net server control.
Though I've never used the browser control in WinForms, I think what you want to use is a Master Page. Assuming what you're rendering in the browser control is an ASPX page, create a Master Page with the hidden text box that you want to grab your data from, and tell all of the pages you want to have that common control on to use your Master Page. When the page renders, the control id will then be "ctl00_TextBoxName". There is no way of getting around the ID concatenation, since unique IDs are needed and that's the only way to guarantee uniqueness with all the nested control abilities of ASP.NET. However, doing this will guarantee you always have that control named the same on every new form you create that inherits the Master Page. Hope that helps!
In summary (because who reads paragraphs?):
Create Master Page
Place your common control in the Master Page
Have your Form inherit the Master Page
You can read up on how Master Pages work in MSDN's Documentation.

Substitution Control at the User Control Level?

I am trying to create some cached user controls. Basically Header and Footer are static.
Except the footer has one link that reads in the URL of the page and puts it into the javascript for sending a link to a friend. So I need that link to be dynamic.
I set up a substitution control and had the static method return the dynamic link.
Go to run and find that substitution controls are not supported at the user control level.
Is there any work around to this? Is there another control like substitution that works on the User Controls that I am not aware of?
I would forget about server side caching in this instance and rely on the simplicity of client side caching.
Your Javascript code could be client side cached just as easily as HTML, either by linking to an external javascript file and adding the necessary headers/expiries, or by embedding the script within the page itself and ensuring the page itself is cached.
Another possible method is by making an Ajax call on the page load to fetch the generated footer complete with correct link. This may take time on the first page load, but subsequent ajax requests would be cached on the client, thus seeing no penalty to future requests.

Resources