So, I have a ChromiumBrowser inside a Windows Form in VB.net.
That form is atached to the "main" parent of the application. When the From is stripped from its parent, it becomes undocked and can be moved outside of the main form. But the moment the parent is removed, the browser is refreshed and I don't want it to do that.
I implemented IResourceHandler to check what method is being called but now the browser won't work because it doesn't know how to handle anything.
Is there a specific handler where I can intercept that call?
Any info is appreciated.
EDIT: Ok, so after reading #amaitland 's comment I changed the URL that I was using to instead load google, and after undocking the form it looks like it is refreshing, but manages to keep the page where it was.
The weird thing is, the default browser does not behave like this.
Related
I am trying to show/hide Tabs depending on a user access level that I pass to my View that contains a Telerik tabStrip as shown below:
#{ Html.Telerik().TabStrip()
.Name("Main_Tabstrip")
.Items(tabstrip =>
{
tabstrip.Add()
.Visible((int)ViewData["UserLevel"] < 2)
.Text("Topic A")
.LoadContentFrom("_TopicATab", "TopicA");
tabstrip.Add()
.Visible((int)ViewData["UserLevel"] < 2)
.Text("Topic B")
.LoadContentFrom("_TopicBTab", "TopicB");
tabstrip.Add()
.Visible((int)ViewData["UserLevel"] < 2)
.Text("Topic C")
.LoadContentFrom("_TopicCTab", "TopicC");
})
However, when I call the Action that generates the View after a change in user status, although the View appears to update (I can step through it and see the UserLevel change) the Tab visibility remains as it was on the first rendering of the view.
If I subsequently refresh the Page either in the browser or via a JavaScript location.reload() call then the Tab Visibility works fine.
Additional information:
The Action referred to above calls View() to Render the full page that contains the above View.
Although I was able to work around the problem on this occasion by doing a page reload in JavaScript, I would really like to know why this was necessary and would appreciate any suggestions or solutions.
(I am posting this as an answer, since it is too long for a comment.)
Sorry, I should have been more specific. I meant from where in the page are you calling the action?
Your action returns some html (generated from the view) that is returned to the browser and one of two things happen depending on how the action was called:
(1) The whole page is replaced (and the browser might change the displayed address depending on the request verb)
(2) A part of the page, for example the content of a div, is replaced.
To accomplish (1) you will probably use a call to Html.ActionLink or an old fashioned anchor tag.
I would however advise you to use (2) instead, since it can give better UX, but it is harder to do. You would make an Ajax call, either via jQuery's ajax method, or an Ajax.ActionLink call.
So basically my counter-question was about which of these you are using. My suspicion is that you are requesting the action, but not writing the response anywhere. Can you perhaps show code for the action and the rest of the view, or reduce it to a minimal example to paste here?
More to the point of your question though, I have looked around a little and you are right that showing/hiding the tabs with javascript is not supported out-of-the-box. I did however find these two posts which might still help you
http://www.aspnetwiki.com/page:extending-the-telerik-mvc-client-api
http://www.aspnetwiki.com/telerik-mvc:dynamically-add-a-tab-to-the-tabstrip
I am talking about list pages in which I am using many filters. Actually these filters are in a user control and are ajaxified. Can I cache the state of the page after applying say 4-5 filters, so that if I move to another page after applying these filters and then return to the original page by pressing back button I will see the same filtered state of the page? I am not changing the url after applying any filters. Can this be done by output caching?
What you're asking for really has nothing to do with caching. Well, it does, but not the kind of caching I think you're talking about :-) FireFox has what is known as the bfcache, which stores the state of a page's DOM as it was when you navigated away from that page. This is used so that when you return to the page, it will look the same as it did when you were there last.
However, certain events cause the bfcache to not be used. For example, this question details how the unload event affects things. If I were you, I would revisit the "I am not changing the url after applying any filters" statement -- I would reccomend storing the state of the page in a docuemnt.location.hash. Here's a question which details that concept
Bear with me on this one!
Right.
Clicking on a link button on a page causes Postback to a page containing a number of controls.
For arguments sake say
page a.aspx containing a link button
containing user controls
control b.ascx
control c.ascx
When clicked
page d.aspx is requested.
During the Postback to (page a) on the server, (page d) is requested when using the IE browser (doesn't happen in Firefox) there are absolutely NO artefacts requested that live on (page d), there are no response redirects or server transfers or anything referencing (page d).
The only thing I have seen like this is when an image or artefact is requested and cant be found, or some pathing issues for an image, and this somehow screws the request up.
Help.
The answer to resolve the problem is:
There was an asp:image element declared without its imageURL attribute set, setting it makes the problem go away. Not declaring the attrbiute caused the default.aspx page in the application to be requested (when using IE). I dont understand why this is the case. Is there something emitted to the client such that the asp:image which, when the imageURL is not defined in IE, a GET request occurs? Any definitive answers would be great.
I'm writing an asp.net web app. and i've hit a bit of a brick wall.
basically i have 2 pages, the main page with a text box in and a popup that contains a treeview.
My problem is this. when i select a treeview item i want the program to perform some database transactions using asp.net and then pass the value retrieved from the database into a javascript function that passes the data back from the popup page to the parent page. My problem is that i cannot find any way of calling a javascript function from asp.net. I've tried assigning attributes to controls on page load, but this does not work as when the page loads the data has not been retrieved from the database.
Have a look at the ClientScriptManager class. You can register scripts from code-behind that will run when the HTML page loads. Those scripts can call other javascript functions on the page.
There are many tutorials and examples on the Web. Here's one I found that may help but there are many more.
How to use the client script manager
You hit the nail on the head when you said "I've tried assigning attributes to controls on page load, but this does not work as when the page loads the data has not been retrieved from the database." You just need to discover when you're pulling the data from the database, and then assign the values after that. Without looking at your code, there's no way to know for sure, but Page_PreRender is probably a good bet to assign your values...it's probably after you're pulling information from the db...it's pretty much the last place that you can make things happen before the html is generated for the client.
You can invoke a function resided in the Main Page and call that function in the Main Page from the Child Page which is your pop up window.
Please refer to these links for references
http://chiragrdarji.wordpress.com/2007/03/10/call-parent-windows-javascript-function-from-child-window-or-passing-data-from-child-window-to-parent-window-in-javascript/
http://www.webmasterworld.com/forum91/2957.htm
http://hspinfo.wordpress.com/2008/01/12/call-parent-windows-javascript-function-from-child-window/
This one helps with retrieving popups from values using javascript
http://www.eggheadcafe.com/articles/20060117.asp
This one shows how to fire a postback using javascript, and manage it in the codebehind.
http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx
If you put them together, and use Control.ClientID to find the actual "html name" of your asp.net controls, you'll be able to set that up in no time.
Might not be the prettiest way to do it in town, and incidentally make little baby Jesus cry, but anyway, it works.
[edit]Oh. I just saw that it seems I answered the question the other way around, or "how to trigger codebehind from Javascript". I think the method I suggest may help you, if you use it right.
The javascript of the popup should pass the information to the parent window, and the parent window function should call a postback when it receives the information.
The javascript of the popup window should be only registered on a postback with the correct information retrieved, so that when the postback occurs on the popup because of the selection of the right information, the window closes and passes the information to the parent page.
The parent page, triggering postback, does the thingies you need it to, and the app resumes "normally" from there on, doing whatever you need it to, outside of the popup page.
Currently we're opening a new aspx page with window.open. The window.open is in a javascript function (openNewWindow()) in the current aspx page which is called when an asp.net hyperlink control is clicked.
The links are dynamically created on the page by our framework and so I'd like to avoid changing that functionality.
The problem seems to be that when this new 'child' window is closed, session state is lost. I should mention that session is available in the child window just not in the 'parent' window after the 'child' window is closed.
Funnily enough, it seems that elsewhere in our application, if an open.window call is added to a page by using a ClientScriptManager.RegisterStartupScript call on the codebehind click event of a hyperlink control (rather than it calling a function that is coded in the aspx) session is preserved.
The latter solution would be difficult to implement in the current framework code without a significant change and all the regression testing that would entail.
Anybody got any ideas how to keep the session state alive after the close of the child window.
BTW this is occurring in IE7 and our app is asp.net 2.0 based.
Thanks in advance for your insightful and elegant solutions to this problem! ;o)
IE 7 changed the behavior of new windows. Basically, each window is opened in it's own process. Tabs are still opened in the same process.
This means that each new window will have it's own cookie bag. Which means that the new window does not have the Sesssion_ID cookie automatically assigned. The .Net link control will send the cookies to the new window. However, just opening a new window with straight javascript probably won't do that.
FireFox has been this way for awhile, and Chrome, I believe, has always been this way. IE 6 and previous shared process space, even for multiple windows so everything was shared between the two which caused no end of headaches for debugging sites strictly in IE.
UPDATE
Here's a link that describes the problem in detail. You'll notice that this behavior is somewhat inconsistent. The reason is that sometimes IE 7 decides to open the new window in its own process, and sometimes it opens it in a new one.
There are two real solutions. Either stop relying on session entirely (my first choice, and I have strong technical reasons for this) or you need to switch to a cookie-less session.
I should correct myself (sorry can't edit the original question) and say that the control firing the javascript to do 'window.open' is a link button not a hyperlink.
It happened in my Chrome also.
I solved this by adding:
<link rel="shortcut icon" href="../../img/favicon.ico">
in <head></head> in page which will be opened.