Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Client Side Button

Author  Topic 

danasegarane76
Posting Yak Master

242 Posts

Posted - 2008-01-04 : 03:47:29
Hi all,
I am using one client side button in my form.The code behind of the form has a public varriable
Action as Integer.If the varraible is 1 then the button has to be disabled else it has to be enabled.I am trying
like this but not working.Can some one help

button class="Btn" id="Button3" title="ALT-D" accessKey="D" onclick="Delete_onclick()"
type="button" >
<% If intAction = 1 then %>
<disabled="true" >
<% Else %>
<disabled="false" >
<%End If %> </button>


Thanks in Advance
Dana

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-01-04 : 13:54:13
It doesn't work because you have already closed the button tag. If you leave the tag open, and then close it after your IF block, that should work fine. Or, you can do it inline using the iif() function if you like this:

<button class="Btn" id="Button3" title="ALT-D" accessKey="D"
onclick="Delete_onclick()" type="button" disable='<%= iif(intAction=1,"true","false")%>'>


Your other option is to put a runat="server" attribute on the button and set it via your ASP.NET code, or use a asp.net button control.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

mukunda
Starting Member

4 Posts

Posted - 2008-01-24 : 06:46:09
Another way is call javascript function on page laod
var flag=<%=intAction%>

function disablebutton()
{
if (flag=="1")
{
document.getElementById("Button3").disabled=true;
}
}

Thanks
Mukund
Go to Top of Page
   

- Advertisement -