if i have multiple submit buttons and the user enters some text in a textbox and presses enter. How can i specify which button event i want to fire?
You can specify for an asp.net Panel the id of button in the property DefaultButton. So, you need to group the controls into panels and then you can specify the default button for any of them. Also, you can specify a default button for the whole page - in the form tag.
Related
I have a clear button and save button ,when i press clear button the required field icon gets clear as the button gets postback,i dont want this to happen i want to show the icon even after clear button is clicked.
You have to specify validation group attribute name for the save button, and set this name on required field validation control
ValidationGroup="validation_name"
In my registration webpage,5 textboxes with required and regular expression validators.click register button means it show all validators properly but suppose click cancel button means it remove the text in all textboxes watever filled.but it showing the validators to fill all the textboxes after filled values in all textbox it allow to remove all text in textboxes otherwise wont...how to do this?
set CausesValidation="False" on the cancel button
Hii.
In my project, in the main page, I've a ASPxPageControl and ASPxPopupControl. In the ASPxPopUpControl, I've a form consits of two radio buttons and so many text fields and combo boxes etc. In the ASPxPageControl, there are two tabs.
The PopUpElement of ASPxPopupControl is in the second tab. And on the PageLoad(), I've configured to display the first tab.
I want to enable/disable texbox in the form according to the user selection of the radio button. But, when AutoPostBack is enabled, the entire page is refreshed, and the default tab will be the first one. And to resume the form, i've to manually click the second tab and the ASPxPopupControl will open automatically.
Is there anyway to resolve this?? Is there any other control other than radio button to do this?(Which accepts client side scripting)
Firstly, Do you need to postback to enable/disable textboxes? you have rich ClientSide Events for Textboxes to enable/disable/hide them (SetVisible, SetEnabled).
Secondly, you can have your second Tab Content in an AspxCallbackPanel, and when Radio Button changes, you Can do a CallbackPanel Refresh (PerformCallback). Thus, only the Tab Content will update.
i am developing a site in asp.net as front-end
In my Form,
i have a 3 text-box with validation control on it eg: requiredFieldValidator
with joinnow button. and search button with 2 textbox with no validation control on it
when i click on search button it is asking me to fill the three text box for validation and it is not redirected to other page
i need that when i click on search button my form should redirect
You need to set the ValidationGroup properties on your textbox that has the validation and the joinnow button to the same thing. When you click the button it will validate controls in its group, and thus not validate from the search button (which is in a different validation group implicitly)
solution for it is
set the property of the search button as below
CausesValidation="False"
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.