Listbox OnSelectedIndexChanged doesn't work - c#

I have a listbox inside my jquery dialog,
<div id="dialog">
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="lbxTitle" runat="server" style="width:400px;height:100px;" OnSelectedIndexChanged="lbxTitle_SelectedIndexChanged">
<asp:ListItem value="2" Text="abc" />
<asp:ListItem value="3" Text="def" />
</asp:ListBox>
<br />
<fieldset>
<asp:Label ID="lblContent" runat="server" style="height:200px;" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
And in the behind code, I have this function
protected void lbxTitle_SelectedIndexChanged(object sender, EventArgs e)
{
lblContent.Text = "test";
}
I dont put autopostback="true" because it will refresh the whole page, and close my dialog.
How to make it so that when user click item on the listbox, it will show "test" on the label inside dialog.
Now, it doesnt do anything if I change the selected item.

You should put the Autopostback then you can use AsyncPostBack to prevent whole page postback...
As per the following Code
<asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:ListBox ID="lbxTitle" runat="server" style="width:400px;height:100px;" OnSelectedIndexChanged="lbxTitle_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem value="2" Text="abc" />
<asp:ListItem value="3" Text="def" />
</asp:ListBox>
<br />
<fieldset><asp:Label ID="lblContent" runat="server" style="height:200px;" />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lbxTitle" />
</Triggers>
</asp:UpdatePanel>

Add AutoPostback and after you create your dialog move it back to the form:
$("#dialog").parent().appendTo($("form:first"));
Try this:
<script type="text/javascript">
$(function() {
<% if (Page.IsPostback) { %>
$('id of your listbox').change();
<% } %>
});
</script>

Related

how use PopupControlExtender with conditions

i have an asp.net Button, i want when a user click on that button:
if there is any Session["id"] for that user, user will be redirect to
another page
2.if not show a PopupControlExtender and show some link
to user
we cant use PopupControlExtender in code behind how i should check this condition ?
thx
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<br />
<asp:Panel ID="Panel1" runat="server" BackColor="#9933FF" BorderColor="#6666FF"
Height="132px" Width="329px">
<asp:Button ID="Button2" runat="server" Text="Button" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Panel>
<asp:PopupControlExtender ID="PopupControlExtender1" runat="server"
TargetControlID="Button1" PopupControlID="Panel1"
>
</asp:PopupControlExtender>
</ContentTemplate>
</asp:UpdatePanel>
What you can do is conditionally register some javascript for opening the Popup when the button is clicked.
Lets say you define your popup like this:
<ajax:PopupControlExtender ID="popup" runat="server"
TargetControlID="textbox"
BehaviorID="mybehavior"
PopupControlID="panel"
Position="Bottom" />
Then, on the button click event:
if(Session["id"] == null)
{
var script = #"Sys.Application.add_load(function() { $find('mybehavior').showPopup(); });";
ScriptManager.RegisterStartupScript(this, GetType(), "ShowPopup", script, true);
}
else
{
//Redirect;
}

FileUpload.HasFile give always false

this is my code where my FileUpload control is outside of update panel but when I click on save button which is under update panel give fileUploadAttachment.HasFile = false
ASPX
<asp:Literal runat="server" ID="lblAttachment" Text="Attachment:" /><asp:FileUpload
ID="fileUploadAttachment" runat="server" Width="488px" />
<asp:UpdatePanel ID="updatePanelAction" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" ValidationGroup="Save" />
<asp:Button ID="btnTest" runat="server" Text="Test" Enabled="false" OnClick="btnTest_Click" />
<asp:Button ID="btnConfirmTest" runat="server" Text="Confirm Test" Enabled="false"
OnClick="btnConfirmTest_Click" />
<asp:Button ID="btnSend" runat="server" Text="Send" Enabled="false" OnClick="btnSend_Click" />
</ContentTemplate>
</asp:UpdatePanel>
CS
protected void btnSave_Click(object sender, EventArgs e)
{
CampaignBAL campaignBAL;
string tmpFileName = "";
User user;
Campaign campaignDetail = new Campaign();
int? campaignID;
if (fileUploadAttachment.HasFile) // return always false
{
tmpFileName = string.Format("{0}\\{1}{2}", Server.MapPath("TempUpload"), Guid.NewGuid(), Path.GetExtension(fileUploadAttachment.PostedFile.FileName));
fileUploadAttachment.PostedFile.SaveAs(tmpFileName);
}
}
please help me how can I fix it
You'll need to add postback triggers for controls that post within the UpdatePanel:
<asp:UpdatePanel ...>
<Triggers>
<asp:PostBackTrigger ControlID="btnSend" />
</Triggers>
...
</asp:UpdatePanel>
You Can Change Your Code in the ASP Page Like This
<asp:updatePanel>
<trigger>
<asp:PostBackTrigger ControlID="btnSend">
</trigger>
<\asp:updatePanel>

post back of Dropdownlist in web user control all other fields become empty

i have a aspx page in which i have placeholder inside the panel
as
<div>
<div>
<div>
<div>
<div>
<div>
<asp:UpdatePanel runat="server" ID="UpdatePanelLinks">
<ContentTemplate>
<center>
<asp:Button Text="ADD" ID="btnAdd" runat="server" Width="100" OnClick="btnAdd_Click" />
<asp:Button Text="Edit" ID="btnEdit" runat="server" Width="100" OnClick="btnEdit_Click" />
<asp:Button Text="Delete" ID="btnDelete" runat="server" Width="100" OnClick="btnDelete_Click" /></center>
<asp:LinkButton ID="usercontroldata" runat="server" Text="Branches"
OnClick="usercontrol_Click"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<div >
<asp:LinkButton ID="lnkDepartments" runat="server" Text="Departments" OnClick="lnkDepartments_Click"></asp:LinkButton>
</div>
<div >
</div>
<div >
<asp:LinkButton ID="lnkProjects" runat="server" Text="Projects" OnClick="lnkProjects_Click"></asp:LinkButton>
</div>
<div >
</div>
<div >
</div>
</div>
<div>
<div>
<asp:Label Text="" Visible="false" ID="lblmessage" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkBranches" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="lnkDepartments" />
<asp:AsyncPostBackTrigger ControlID="lnkProjects" />
<asp:AsyncPostBackTrigger ControlID="btnAdd" />
<asp:AsyncPostBackTrigger ControlID="btnEdit" />
<asp:AsyncPostBackTrigger ControlID="btnDelete" />
</Triggers>
<ContentTemplate>
<asp:Panel runat="server" ID="MainPanel">
<div class="padding_branch">
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</div>
</div>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkBranches" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="lnkDepartments" />
<asp:AsyncPostBackTrigger ControlID="lnkProjects" />
<asp:AsyncPostBackTrigger ControlID="btnAdd" />
<asp:AsyncPostBackTrigger ControlID="btnEdit" />
<asp:AsyncPostBackTrigger ControlID="btnDelete" />
</Triggers>
<ContentTemplate>
<asp:Panel runat="server" ID="MainPanel">
<div >
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
and on the aspx.cs page i am dynamically add the web user control on click of links
and on the add button click the new user control is loaded
protected void usercontrol_Click(object sender, EventArgs e)
{
if (ViewState["controlname"] != null)
{
PlaceHolder pl = MainPanel.FindControl(ViewState["controlname"].ToString()) as PlaceHolder;
if (pl.Controls.Count > 0)
{
pl.Controls.RemoveAt(0);
}
}
Control uc = (Control)Page.LoadControl("~/usercontrol_Data.ascx");
ViewState["path"] = "~/usercontrol_Data.ascx";
ViewState["controlname"] = "PlaceHolder1";
ViewState["name"] = "usercontrol";
PlaceHolder1.Controls.Add(uc);
}
i am also mainaining the web user control on Page_Load
if (Page.IsPostBack)
{
if (ViewState["path"] != null)
{
Control uc1 = (Control)Page.LoadControl(ViewState["path"].ToString());
PlaceHolder pl = MainPanel.FindControl(ViewState["controlname"].ToString()) as PlaceHolder;
pl.Controls.Add(uc1);
}
}
and there is dropdown list on the form user control when iam selecting any of the option from the user control it post back and all the other fields become empty for textboxes etc . this happans for the first time and for next time all the fields retain there values
please help
thanks
i have done this by assigning the same ID to the control every time when the control loads dynamically. this is because when the control added dynamically every time it get the new ID that is creating the problem for me
uc1.ID="Web_User_Control_ID";
every time the control load asign this ID to it will resole the problem
Try changing Page.IsPostBack to !Page.IsPostback in your Page_Load event.
Dynamically added controls are not persisted between post backs; you have to re-add your dynamically added controls on each post back. On each page request, asp.net will parse your aspx file, build the html structure of your page, then fill in any previously filled-in values via ViewState and posted values, then serve it up. That's it. It will never automatically re-add dynamically added content.
So once you run this code
protected void usercontrol_Click(object sender, EventArgs e)
{
//...
Control uc = (Control)Page.LoadControl("~/usercontrol_Data.ascx");
ViewState["path"] = "~/usercontrol_Data.ascx";
ViewState["controlname"] = "PlaceHolder1";
ViewState["name"] = "usercontrol";
PlaceHolder1.Controls.Add(uc);
}
you need to somehow know to re-run it every time the user posts back

ASP.NET: ModalPopupExtender prevents button click event from firing

Here is what I'm trying to do: Click a button on my page, which in turn makes (2) things happen:
Display a ModalPopup to prevent the user from pressing any buttons or changing values
Call my code behind method, hiding the ModalPopup when finished
Here is the ASP markup:
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true"
UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSaveData" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlHidden" runat="server" style="display: none;">
<div>
<h1>Saving...</h1>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="modalPopup"
BackgroundCssClass="modalBackground" runat="server"
TargetControlID="btnSaveData" PopupControlID="pnlHidden"
BehaviorID="ShowModal">
</cc1:ModalPopupExtender>
<asp:Button ID="btnSaveData" runat="server" Text="Save Data"
OnClick="btnSaveData_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Now, here is my code behind C# code:
protected void btnSaveData_Click(object sender, EventArgs e)
{
UpdateUserData(GetLoggedInUser());
modalPopup.Enabled = false;
}
Why doesn't this work? The ModalPopup displays perfectly, but the btnSaveData_Click event NEVER fires.
UPDATE: The first suggestion did not work for me. I also tried your second suggestion (insofar as it applied to me). One minor difference on my end is that there is no button on my modal panel (pnlHidden) -- it's just a message. I did try using Javascript events on the client side, which at least did fire concurrently with my server-side event. This was good news, but I can't seem to find or grab a handle on the ModalPopupExtender or its BehaviorID. This doesn't work:
function showOverlay() {
var popup = $find('modalPopup');
popup.show();
}
popup is ALWAYS equal to null.
FINAL UPDATE: This is my final solution for getting this to work (Take specific note of the use of OnClientClick AND OnClick):
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true"
UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSaveData" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlHidden" runat="server" style="display: none;">
<div>
<h1>Saving...</h1>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="modalPopup"
BackgroundCssClass="modalBackground" runat="server"
TargetControlID="hdnField" PopupControlID="pnlHidden"
BehaviorID="ShowModal">
<asp:HiddenField ID="hdnField" runat="server" />
</cc1:ModalPopupExtender>
<asp:Button ID="btnSaveData" runat="server" Text="Save Data"
OnClientClick="showModal();" OnClick="btnSaveData_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Using this Javascript function:
function showModal() { $find('ShowModal').show(); }
... And this code behind:
protected void btnSaveData_Click(object sender, EventArgs e)
{
UpdateUserData(GetLoggedInUser());
modalPopup.hide();
}
Try this.
Create a dummy hidden field:
<asp:HiddenField ID="hdnField" runat="server" />
Set the TargetcontrolID = "hdnField" in your Modal Popup declaration.
In your btnSaveData_Click event, do this:
modalPopup.Show();
Try this. It is 100% working
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Btnshow" runat="server" Text="Show" OnClick="Btnshow_Click" />
<asp:Button ID="BtnTarget" runat="server" Text="Target" Style="display: none" />
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
<input type="button" value="Get" onclick="abc()" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="BtnTarget"
PopupControlID="Panel1">
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" BackColor="Black" Width="300px" Height="300px">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="BtnHide" runat="server" Text="Hide Button" OnClick="BtnHide_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnHide" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Btnshow" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Server side code
protected void Btnshow_Click(object sender, EventArgs e)
{
ModalPopupExtender1.Show();
}
protected void BtnHide_Click(object sender, EventArgs e)
{
ModalPopupExtender1.Hide();
}
First attempt: Try to set your ButtonID into OkControlID Tag and try again
OR
Second attempt: Call your event over javascript there seems to be some problems with click events
<div>
<cc1:ModalPopupExtender PopupControlID="Panel1"
ID="ModalPopupExtender1"
runat="server" TargetControlID="LinkButton1" OkControlID="Ok"
OnOkScript="__doPostBack('Ok','')">
</cc1:ModalPopupExtender>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</div>
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="Ok" runat="server" Text="Ok" onclick="Ok_Click" />
</asp:Panel>
From this example you can easily control panel show up depends on conditions instead of just immediately show up panel once you click button.
<asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click"/>
<asp:HiddenField ID="hdnField" runat="server" />
<ajaxToolkit:ModalPopupExtender runat="server"
TargetControlID="hdnField"
ID="btnAdd_ModalPopupExtender"
PopupControlID="pnlPrintName">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPrintName" runat="server">
.
.
</asp:Panel>
//Server side code:
protected void btnAdd_Click(object sender, EventArgs e)
{
if( dt.Rows.Count == 0 )
{
btnAdd_ModalPopupExtender.Show();
}
else
{
add();
}
}
In code behind, you can do this:
if (true)
{
var script = #"Sys.Application.add_load(function() { $find('behavoirIDModal').show(); });";
ScriptManager.RegisterStartupScript(this, GetType(), "Show", script, true);
}
Change this 'behavoirIDModal'

JQuery to enable,disable textbox is not working consistently

I have a DropDownList as a custom control inserted into a subform which is within a popup window on my main page. I have coded unique CssClass identifiers for both the DropDownList and the textbox I am trying to enable/disable. I only want the textbox enabled for DropDownList values 317 and 318, all others should disable the textbox. Here is the problem... If I bring up my popup window and select an action other than 317/318, it disables the textbox as expected. Then if I change my mind and select 317 or 318 it DOES NOT enable the textbox. This seems real strange that it partially works.
I have the following jquery code in my main page:
<script language="javascript" type="text/javascript">
var _CASE_RESERVE_ACTION = "317";
var _LEGAL_RESERVE_ACTION = "318";
function pageLoad() {
$(".statusActionDDLCssClass").change(function() {
var value = $(this).val();
if (value == _CASE_RESERVE_ACTION || value == _LEGAL_RESERVE_ACTION)
$(".statusActionAmountCssClass").attr('enabled', 'enabled');
else
$(".statusActionAmountCssClass").attr('disabled', 'disabled');
});
}
</script>
Here is the custom control with the DropDownList:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="StStatusActionLookup.ascx.cs" Inherits="Company.Solutions.Web.Controls.StStatusActionLookup" %>
<div id="mainControlContainer" style="width:99%; padding:8px;">
<div id="comboContainer" style="float:left; padding-top:12px;padding-left:5px; padding-right:5px; padding-bottom:3px;">
<asp:UpdatePanel ID="update1" runat="server" UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="chkComments" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="chkDenials" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="chkOther" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList runat="server" ID="ddlLookup" width="240px" CssClass="statusActionDDLCssClass" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="filterContainer" style="text-align:left;padding-left:6px;width:275px">
<fieldset style="width:260;">
<legend>Filters</legend>
<asp:CheckBox ID="chkComments" runat="server" Text="Comments" AutoPostBack="true" />
<asp:CheckBox ID="chkDenials" runat="server" Text="Denials" AutoPostBack="true" />
<asp:CheckBox ID="chkOther" runat="server" Text="Other" AutoPostBack="true" />
</fieldset>
</div>
</div>
And here is my subform with the text box (txtStatusActionAmount):
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="StatusActionAddSubform.ascx.cs"
Inherits="Company.Solutions.Web.Controls.StatusActionAddSubform" %>
<%# Register TagPrefix="st" TagName="StatusActionLookup" Src="~/Controls/StStatusActionLookup.ascx" %>
<div class="NinetyNinePercentWide">
<div class="NinetyNinePercentWide EightPixelBottomMargin">
<div class="RowHeader" style="padding-top: 20px;">
<span>Action:</span>
</div>
<div>
<xy:StatusActionLookup ID="statusActionLookup1" runat="server" />
</div>
</div>
<div class="NinetyNinePercentWide EightPixelBottomMargin">
<div class="quarterWidthDiv">
<span>New Status:</span>
<asp:Literal runat="server" Text=" " ID="spc2" />
<asp:DropDownList runat="server" ID="ddlNewStatus">
<asp:ListItem Selected="True" Value="" Text="" />
<asp:ListItem Value="01" Text="Open" />
<asp:ListItem Value="02" Text="Closed" />
</asp:DropDownList>
</div>
<div class="quarterWidthDiv">
<span>Date:</span>
<asp:Literal runat="server" Text=" &nbsp" ID="spc1" />
<asp:TextBox ID="txtStatusActionDate" runat="server" Columns="10" MaxLength="10"
Style="width: 35%;" CssClass="statusActionDate" />
<cc1:CalendarExtender ID="txtStatusActionDate_CalendarExtender" runat="server" Enabled="True"
TargetControlID="txtStatusActionDate" />
<cc1:MaskedEditExtender runat="server" ID="txtStatusActionDate_MaskedEditExtender"
Enabled="True" Mask="99/99/9999" MaskType="Date" TargetControlID="txtStatusActionDate"
UserDateFormat="MonthDayYear" />
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtStatusActionDate"
Type="Date" Operator="DataTypeCheck" ErrorMessage="Invalid Date" > </asp:CompareValidator>
</div>
<div class="quarterWidthDiv">
<asp:Label runat="server" ID="lblStatusActionAmount" AssociatedControlID="txtStatusActionAmount"
Text="Amount:" />
<asp:TextBox ID="txtStatusActionAmount" runat="server" Style="width: 30%;" CssClass="statusActionAmountCssClass" />
</div>
<div class="quarterWidthDiv">
<asp:Label runat="server" ID="lblClaimant" AssociatedControlID="ddlClaimant" Text="Claimant:" />
<asp:DropDownList ID="ddlClaimant" runat="server" onchange="mailOrStatusActionTextChanged()">
<asp:ListItem Selected="True" Value="" Text="" />
<asp:ListItem Value="1" Text="Primary" />
<asp:ListItem Value="2" Text="Secondary" />
</asp:DropDownList>
</div>
</div>
<div class="NinetyNinePercentWide EightPixelBottomMargin" style="margin-top: 2px;">
<div class="RowHeader">
<asp:Label runat="server" ID="lblStatusActionReason" AssociatedControlID="txtStatusActionReason"
Text="Reason:" />
</div>
<div style="padding-left: 12px;">
<asp:TextBox ID="txtStatusActionReason" runat="server" TextMode="MultiLine" Rows="2"
MaxLength="25" CssClass="StatusReasonWidth" onchange="mailOrStatusActionTextChanged()" />
<asp:CustomValidator ID="cstmValStatusActionReason" runat="server" ControlToValidate="txtStatusActionReason"
ErrorMessage="String is too long" />
</div>
</div>
</div>
Thank you,
Jim in Suwanee, GA
I don't believe there is a 'enabled' property of form elements, try
$(".statusActionAmountCssClass").attr('disabled', false);
EDIT
Note that the meaning and usage of attr() has changed in jQuery 1.6. While the above will probably still work, make sure to test and understand the difference between attr() and prop()
http://blog.jquery.com/2011/05/03/jquery-16-released/
In the 1.6 release we’ve split apart the handling of DOM attributes
and DOM properties into separate methods. The new .prop() method sets
or gets properties on DOM elements, and .removeProp() removes
properties. In the past, jQuery has not drawn a clear line between
properties and attributes. Generally, DOM attributes represent the
state of DOM information as retrieved from the document, such as the
value attribute in the markup . DOM
properties represent the dynamic state of the document; for example if
the user clicks in the input element above and types def the
.prop("value") is abcdef but the .attr("value") remains abc.
$(".statusActionAmountCssClass").attr('disabled', true) won't work
use :$(".statusActionAmountCssClass").attr('disabled', 'disabled')
and $(".statusActionAmountCssClass").removeAttr('disabled', 'disabled')
this will work
This is how i do it.
$("input[name='votingmode']").change(function () {
if ($("input[name='votingmode']:checked").val() == '1') {
$("#plusplus").attr("disabled", "disabled");
$("#minusminus").attr("disabled", "disabled");
} else if ($("input[name='votingmode']:checked").val() == '3') {
$("#plusplus").removeAttr("disabled", "disabled");
$("#minusminus").removeAttr("disabled", "disabled");
});

Categories