Disabling the asp.net link button n radios using Jquery - asp.net

How to disable the asp.net Link buttons and asp.net radio buttons.
I have used
to enable
$("#sLbtnFirst").attr("disabled", "");
to disable
$("#sLbtnFirst").attr("disabled", "disabled");
but i'm able to click the buttons they are just greying

In .NET radio buttons, the attribute that specifies whether they're clickable is called "enabled", not "disabled".
But, at client-side they are rendered as html input tags which do contain the attribute "disabled" so to disable them you would want to use:
$("#sRbtnFirst").attr("disabled", "disabled");
To enable:
$("#sRbtnFirst").removeAttr("disabled");
EDIT: I've tried your jQuery myself in a .NET app and it seems to grey out the radio buttons fine (and prevent clicking). The LinkButton's a different story though.
You'll also need to remove the "href" attribute to prevent it from performing an action on click. So:
$("#sLbtnFirst").attr("disabled", "disabled");
$("#sLbtnFirst").removeAttr("href");
That should disable the LinkButton.
Also, remember that your IDs will change when they are rendered in the form so they won't be what they are when you view your aspx page in Visual Studio. .NET will change them into something like:
#ct100_sLbtnFirst

Link buttons render as anchor tags (<a href=) and the disabled attribute is not defined for this tag. As far as radio buttons are concerned you could apply the disabled attribute to them, they will grey out and their value won't be sent when you post the form.

To enable/disable linkbutton, try this:
//disabling
document.getElementById('sLbtnFirst').onclick = function() {return false;}
//enabling
document.getElementById('sLbtnFirst').onclick = function() {return true;}

You should use:
$("#sRbtnFirst").removeAttr("disabled");

Related

How to disable RadNumeric TextBox, but with working spinbuttons?

I have a Telerik RadNumericTextBox that has spinbuttons to increment/decrement the value. I want to prevent the user from entering their own input and to only use the spinbuttons. When I try to disable the textBox or make it readonly, the buttons are disabled as well. Is it possible to keep the buttons functional and make the textBox only for display?
I have certain attributes on this control that I need so continuing to use a Telerk RadNumericTextBox would be more convenient than using other controls.
$telerik.$($find("Numeric1").get_element())
.focusin(function(){ this.readOnly = true; })
.focusout(function(){ this.readOnly = false; });
Working on this page http://demos.telerik.com/aspnet-ajax/input/examples/radnumerictextbox/firstlook/defaultcs.aspx

Asp.Net - Is there a way to set attribute to all controls of the application?

I have a system and I had a problem today, when the user double-click on button control and the system process the operation twice.
I found a solution with this code on the button:
OnClientClick = "this.disabled = true; this.value = 'submiting ...';" UseSubmitBehavior = "false"
However, I have several pages in the system, with several buttons ... is there any way to set these attributes to all the buttons of the application?
Thank you!
What about using a clientSide approach by using JQuery and disabling all Submit controls (jsfiddle)
$(document).ready(function () {
$(' :submit').click(function (event) {
$(this).attr("disabled","true");
});
});​
I am quite new to JQuery so if there are any better solutions or I am completly wrong, pls let me know!
I'm not sure, but it seems that it is possible through skin file.
You can create a custom button. Here you have example how to create button that displays confirm window on client click. Almost what you wan't.
http://dhavalupadhyaya.wordpress.com/2008/07/20/creating-custom-controls-in-asp-net/
Than you would have to change all the asp:Buttons on every page to someTag:YourButton. Maybe simple Find/Replace. But I think there is possibility to configure in web.config so that ASP.NET uses someTag:YourButton everytime it sees asp:Button. But can't find now how to do it.

disable jquery datepicker

I have used jquery datepicker in my .aspx page. The control is working fine. What i need is to disable the control if the textbox on which it is linked is disabled. For ex. I am showing datepicker on textbox "txtDateOfAssignment". If the Enabled property of this textbox is false then datepicker should not be active on that.
Anybody have an idea?
Thanks in advance.
if you look at the documentation you'll notice that there is a "disable" method, so you can do :
$('id-of-your-textbox').datepicker('disable');
Ok, finally you're not using jquery-UI but jquery-datepicker, so it should be more something like as referred to the documentation here
$(document).ready(function () {
$('.date-picker').dpSetDisabled(true);
});
If you want to disable only 1 datepicker dont use the class selector ".date-picker" but the id of the datepicker you want to disable.
Another possible Solution is
var j$=jQuery.noConflict();
j$("#inputTextID").datepicker(('disable' ));
j$("#inputTextID").datepicker(('enable' ));

Get access to ASP.Net CreateUserWizard buttons

I'm using a CreateUserWizard on my register page. The Sign Up button is part of a CustomNavigationTemplate.
I need to set the Sign Up button as the default button of a ASP:Panel, but can't do so since it's inside the template. I tried to do so, but I can't locate the Sign Up button using CreateUserWizard.FindControl, CreateUserWizard.WizardSteps(0).Controls(0).FindControl or other similar steps (this is a known issue with this control).
Any ideas on how I can expose this button, or set it as the panel's default button in some other way?
Here's how I finally did it:
Referencing the CreateWizard Button and assigning to Panel's Default Button:
Dim RegisterButton as Button = Ctype(CreateUserWizardStep1.CustomNavigationTemplateContainer.FindControl("RegisterButton"), Button)
RegisterPanel.DefaultButton = RegisterButton.ID 'Or RegisterButton.UniqueID
I wasn't able to use the above, because it was giving me the error "The DefaultButton of 'RegisterPanel' must be the ID of a control of type IButtonControl"
I finally created a dummy button called "RegisterButton" (same name as the register button inside the template) and hid it using CSS, and gave it's OnClick the 'real' register button's function call.
For the login section, I used this:
Page.Form.DefaultButton = LoginButton.UniqueID

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn't do the "Ok". Instead I have to manually click on Ok to Submit. How can I do by pressing Enter on my Keyboard rather than Clicking on "Ok" button after selecting the value from dropdown list. I have set the SubmitBehavior to true.
Try the solution here: ASP.NET 2.0 - Enter Key - Default Submit Button.
Assuming you're talking about a web form:
I'm no ASP.NET guru, but the default behavior of an HTML form is to submit in this case. Common causes for this are the HTML form fields not being contained within the form element, or the submit button having a nonstandard javascript function fire instead of submitting proper.
I realize that's not an answer, but I hope it might help.
using jquery you can do something like this
$("#fieldName").keypress(function(event)
{
if (event.keyCode == 13)
{
return true;
}
else
{
return false;
}
});
See more here: http://docs.jquery.com/Events/keypress
Try setting Page.Form.DefaultButton = OkButton; in your code-behind.

Resources