Unable to click master page button in ASP.NET - asp.net

I have put sign out button in master page. I have a page in which I use that master page and I also have update panel in this page. When I click on sign out button , it does not work. When I use anchor tag it works but I want to use Button.
Thanks,

this might be happen if you are using requiredfield validations for some input fields. try
CausesValidation="false"
for the button control and check. hope this help you.

I had the same problem and I solved deleting the main div nested in the asp Content placeholder. For me all the controls inserted in the masterpage was freezed, buttons, dropdown box, all in other words.

Related

Show asp.net UpdateProgress control on submit only

I have a page with 2 buttons on.
I want to show the updateprogress only when the page is submitted via one of the buttons, but not the other cancel button. I've been struggling for a while to come up with a solution.
Anyone know how I can do this?
Add parameter AssociatedUpdatePanelID for UpdateProgress, and set AsyncPostBackTrigger for UpdatePanel to button you want to make a postback.
If above instructions doesn't help, you can also try to wrap controls you need into asp:Panel control and set DefaultButton to your Submit button ID.

Display bottom of page after clicking button in ASP.NET

I'm using VS2010/C# to develop my ASP.NET web project. I want my users to view bottom of page after clicking on a button. How can I do so? Can I use JavaScript, and if so, what is the function I should use?
Use an Anchor tag?
The Link
bottom
This would be at the bottom of the page:
<a name="bottom"></a>
If you want this behavior on an ASP.NET control like a <asp:button> and not a regular link for your button, then on the PostBack in your code-behind, you'd need to do something like below to spit out some JavaScript to jump the user down to that position.
ClientScript.RegisterStartupScript(this.GetType(), "Anchor", "location.hash = '#bottom';", true);
Use a html anchor tag to link to an anchor at the bottom of the page.
you simply need to use client side HTML Anchor, links with:
href=#bottom
see here for info: http://www.echoecho.com/htmllinks08.htm

Button, UpdatePanel and MasterPage

I have asp.net application and a TabContainer from AjaxControlToolkit on a form. There are 4 tabs, each containing UpdatePanel, hidden button and some custom .ascx (each with it's own javascript file). Buttons are triggers for panels to update the contents and they are triggered from the 'OnClientActiveTabChanged' event of the TabContainer.
This technique is described here and similiar here. It's pretty simple when looking at it.
The only problem I have is that the whole scenario works when used as a separate page but it doesn't seem to work when masterpage is around that page. Suddenly buttons act as full postback controls.
Do you have any idea what's the reason?
Assuming the buttons your referring to are on the master page, I think you'll want to register the master page buttons as update panel triggers.
http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers

Is there a way to open another page using ModalPopup Extender?

I was wondering if there is way to open another page using a Modal Popup Extender?
and if there is can someone please the tell me how do i go about doing it ..
Thanx
Owais
You could probably put an iframe pointing to the page within the Modal Popup Extender, however that would be a bit of a hack. I would recommend putting whatever content on that page into a user control and then referencing that control from both the original page and the page with the modal popup.
Try using an HTML iframe as the target control of the extender. The iframe tag has a "src" attribute that should point to the page you want to show in the dialog.
You have to think about it w/o the illusion - fundamentally the modal popup is just a DIV. So the question is "can you display a different page in a div?". Iframe... or perhaps a webservice call.
you can use a user control and load it dynamically into the modal popup
Dim ctrl As Control
ctrl = Me.Page.LoadControl("~/control/cmsbar.ascx")
ctrl.id="ctrlx"
Placeholder1.Controls.Add(ctrl)
popup.Show()
note that the popup will have a placeholder to add the control to. you must give the user control an id so the viewstate can be loaded for the control . this code must be placed in the Page_Init event so when the user control is created for the second time it loads its view state

ASP.NET default button

I have a master page with a search box and button at the top. This search functionality is taking over the "enter" key for all my web forms that use this master page. That is, if I have a login page that uses this master page and the user enters in their username/password and hits "enter", instead of logging in the user the system performs a search.
What's the best way to set up the default submit buttons. I could wrap everything in asp Panels and set the DefaultButton property, but that seems a bit tedious. Is there a better way?
use defaultbutton property of form or panel
<form defaultbutton=“button1” runat=“server”>
<asp:button id=“button1” text=“Same Page” runat=“server”/>
<asp:panel defaultbutton=“button2” runat=“server”>
<asp:textbox id=“foo” runat=“server”/>
<asp:button id=“button2” runat=“server”/>
</asp:panel>
</form>
As you have discovered default buttons can cause issues when there is more than one button on a page. I would take the Geeks suggestion but simplify it by removing the setfocus client script and extend it by adding the keydown event to both the search textbox and the login textboxes such that the enter key fires the correct button depending on if your user is using the search box or the log in box, or any other textbox you want to add the javascript to.
You can set focus on loading the page (in code behind if you like) to save the user some mouse work or tabbing if there is a sensible control for the user to start at, but otherwise the control the user is interacting with should determine the flow of the page and what the enter key does.
set focus on the text box ,
Page.RegisterStartupScript("SetFocus", "< script >document.getElementById('" + TextBox1.ClientID + "').focus();< /script >");
and then
In the keydown event for the last textbox you can do something like this:
If e.KeyCode = Keys.Enter Then
Me.Button1.Select()
End If
Rather than using javascript to manipulate the page you could put the search box and the submit button into an IFRAME on the master page. If the focus is in the iframe clicking will submit the search form, if the user is on your main form within the page they will submit the normal page.
The <iframe> src attribute points to a little self contained aspx page holding your text box and submit button which redirects to your search results form.
This is what we tried on our project which seemed to work. I changed the Search asp:Button to be an asp:LinkButton. I then added some CSS style to give it a background image to make it look like a button. LinkButtons are apparently not used by the page for determining which Button is the default action when pressing Enter. The sweet part was that LinkButton can still have click actions associated with them so I didn't have to change any of my code-behind stuff.

Resources