I have a aspx page. By default, when the page loads the focus is on first textbox. I want to remove the focus to nothing. I am developing this website for a mobile device.
We have come to this nothing conclusion due to some cross browser restrictions we faced with IE.
Page.Focus(); in the init is not working and I don't want to set up the focus to anything.
This information is all I have. Hope it is sufficient for possible resolution.
I will appreciate your feedback and time spend on this query...
An alternative can be to create a hidden control and move the focus to that control
If you're able to use jQuery why don't you do
$('#idOfInputWhichKeepsOnGettingFocus').blur();
If not, create a new first field
<input id="youCannotSeeMe" style="position:absolute; left:9001px;" />
This works:
Page.SetFocus(this);
Related
I'm working on a little project with ASP and C#.
In my project I'm using a masterpage for the navigationbar on the top of my pages, looking like that:
The navigationbar contains some normal navigation-points and one to log out with float: right;
On all of my diffenrent pages this works excepted for one.
The only difference is, that on this special page I have some textbox-elements like this:
<asp:TextBox ID="tbTOP1sum" runat="server"></asp:TextBox>
As soon as I only enter one of this textboxes my navigationbar looks like that:
It doesn't matter what sort of element im adding, everything is okay, excepted with this textboxes.
I noticed that this only happens in Google-chrome, not with Firefox and not with Internet-Explorer or Edge. Another thing i found out is, that disabling and enabling the CSS-rule in Chrome-Page-Inspector fixes the problem.
I have no idea what to do...
Thanks in advance for your help!
I have the same issue sometimes. When you change it in the inspector go into your code and make the same change and save/build, go to the web browser and do a hard refresh with "ctrl+F5". If it still does not work, wrap your logout a link in a div and then call it in CSS. Set the position to relative, and then put the top: -55px;
It finally turned out, that adding display: inline; to the of the navigationbars <ul> is all to do.
Another way is to do it with table columns. One for the normal content and one for the logout.
Thanks for the other answers!
I have an application that uses WebBrowser control to navigate from page to page, on some pages I get a leaving popup asking me if that's what I want to do.. this stops the whole further execution until I press "Leave" or "Stay".. How can I disable them?
What I've tried so far were these actions:
a) setting window.onbeforeunload = null;
b) setting alert, confirm, prompt to an empty function
c) settin suppressErrorMessages to true
but even so, I still get the nasty message in the end.
I mostly relied on this answer:
How to update DOM content inside WebBrowser Control in C#?
But so far without a success.
The alerts seem to be jQuery alerts because they have custom texts (instead of OK Cancel, they have Stay Leave)..
Any help hugely appreciated!!
The webbrowser control uses IE internally and IE has a prompt if you've filled out a form asking you if you really want to leave the page (thereby losing the content you've filled out) perhaps that's what you're seeing?
i'm just shooting from the hip here but you could try clearing all inputs before navigating.
I hope I can explain this well without having to post scads of source.
I have a page in an online store that lets the user pick a date for a tour. That page has a ConLib which contains a couple of panels. The first is:
<asp:Panel ID="pnl_Grid" runat="server">
<cb:SortedGridView ID="VariantGrid" runat="server"
AutoGenerateColumns="False" Width="100%"
SkinID="PagedList" DataKeyNames="OptionList">
<Columns>
</Columns>
</cb:SortedGridView>
</asp:Panel>
and then another asp:Panel with other stuff - calendar, buttons, etc. The SortedGridView is supplied by our shopping cart provider and is basically a regular asp:Grid.
When the user says they want 3 tickets I do a
pnl_Grid.Enabled="false"
to keep them from changing it after picking a date/time. At various points they can click a reset button that will do many things but one task is to set the value to zero in the gridrow text boxes and enable the Grid since they reset the process and want to pick new things.
I have stepped through the code with breakpoints in place and it seems that the problem I am having is that my reset button click event handler fires after the Grid is rendered with the disabled status in the Page Render stage of life. If that is true then setting the Grid in code behind will never show the enabled grid on the page without a refresh since it's already rendered. If I refresh the page manually it does indeed show as enabled so I think I'm on the right problem.
My question is twofold, if there is enough info here to answer it:
1. Is it likely that what I think I am seeing is true - the page renders the control disabled and then the button handler tries to enable it but it's too late at that point since the control is already rendered?
2. How can I work around this? I would prefer to avoid JQuery if at all possible... it has some unintended side effects with the way our original store software is written.
Further info:
I have a status flag _EventSelected which tells if the calendar event has been selected. On the reset button click I set that to false and on PreRender I check that to see if it is false and enable the Grid. Again, the status doesn't change until the Reset Button Click event handler and that is after the PreRender.
Thanks for your input! I swear, some days ASP.NET makes perfect sense to me and other days it is clear as mud.
I found a working solution. To force the page to refresh after the button enables the Grid, which is not displayed without the refresh, I added this to the btn_Reset_Click handler, found by searching for "cause page reload":
Page.Response.Redirect(Page.Request.Url.ToString(), false);
It's not a bad solution since I'm in a reset / start-over state anyway. Thanks for taking time to read my question! Hopefully this will help someone else some day.
It is me or Page.Form.DefaultButton doesn't seem to work in a page with no input ? I tried looking for this information but found nothing. Cause right now I am on a page where I set the default button and this doesn't work at all.
I seem to recall this is a known issue.
You can also set a DefaultButton on an <asp:Panel> - is it practical for you to do this instead?
Actually thinking about it further I think if you add a hidden input on the page it would also fix your issue.
Try to set the default button to the specific panel or content.
Try that an let me know....
in my application i have the playvideo page where video will play, below that i have the option for sharing the video like adding to favorite ,playlist and sending mail.
when i click on any of the link the page is postbacking and video will start from the first.
i place update panel for link button even though it is not working (video is playing from the first i.e., page is postbacking. can u help me. thank you
Actually, the part of page that is within the UpdatePanel does the postback. Make sure you have only those controls(for instance, your links) inside the UpdatePanel.
Alternatively, you can use multiple UpdatePanels; for instance one for your video and one for the links. In this case note that, when one UpdatePanel gets updated other UpdatePanels also gets updated, which you may not want; so all you have to do then is to mark the UpdateMode property to Conditional and call YourDesiredUpdatePanel.Update() method manually - whenever required.
Btw, updating selected portions of the page also reduces the load on the server
Or you may want to look into using client callbacks instead of a postback. But since client callback uses XMLHTTP, which means Microsoft implementation of AJAX, therefore callbacks are just awesome as long as your are working with IE.
You might want to try taking advantage of Page Methods to do the work you need done server side.
http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Also, if you want to prevent a control from posting back, you can add return false to the end of your javascript onclick event on the control.
For example, if you had an asp button you were using you could do this:
<asp:Button ID="myButton" runat="server" OnClientClick="DoThingsInJavascript(); return false;" />
Or if you were just using a standard button you could say:
<input type="button" onclick="DoThingsInJavascript(); return false;" />
I've never really liked the update panel and I have sometimes found it's behaviour awful. Have you thought of trying something like a proper ajax call from Javascript