1jaws
asked on
disable button
I have a one RadUpload and one RadButton - called Upload... I want to hide RadButton unless user Selected a file from RadUpload.. how can I do that?
when file is uploaded set RadButton.visible = false
ASKER
thank you for replying... I am disabling the RadButton unless user clicked RadUpload's Select button and selected a file to upload.. basically, I need to check if there is a file shows on that textbox's of the RadUpload
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok but this is not RadUpload, it is regular input type .. file.. cant I do that with RadUpload?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
used second link.. I get this error
Microsoft JScript runtime error: 'FileInputField.value' is null or not an object
function myOnClientFileSelected(rad Upload, eventArgs)
{
var selectedFileName = eventArgs.FileInputField.v alue.toLow erCase(); <---gives error when page loads because no file name selected yet...
if(selectedFileName != null)
{
btnUpload.disabled = "false";
}
}
Microsoft JScript runtime error: 'FileInputField.value' is null or not an object
function myOnClientFileSelected(rad
{
var selectedFileName = eventArgs.FileInputField.v
if(selectedFileName != null)
{
btnUpload.disabled = "false";
}
}
Check for null value like below
function myOnClientFileSelected(rad Upload, eventArgs)
{
if(eventArgs != null && eventArgs.FileInputField != null)
{
var selectedFileName = eventArgs.FileInputField.v alue.toLow erCase(); <---gives error when page loads because no file name selected yet...
if(selectedFileName != null)
{
btnUpload.disabled = "false";
}
}
}
function myOnClientFileSelected(rad
{
if(eventArgs != null && eventArgs.FileInputField != null)
{
var selectedFileName = eventArgs.FileInputField.v
if(selectedFileName != null)
{
btnUpload.disabled = "false";
}
}
}
ASKER
I did and nothing happening.. my button still disabled... something not right.. here my code... I made btnUpload enabled = false at the beginning so made that enabled true...below..
function myOnClientFileSelected(Rad Upload, eventArgs) {
alert("hi");
if(eventArgs != null && eventArgs.FileInputField != null)
{
var selectedFileName = eventArgs.FileInputField.v alue.toLow erCase();
if(selectedFileName != null)
{
btnUpload.enabled = "true";
}
}
}
function myOnClientFileSelected(Rad
alert("hi");
if(eventArgs != null && eventArgs.FileInputField != null)
{
var selectedFileName = eventArgs.FileInputField.v
if(selectedFileName != null)
{
btnUpload.enabled = "true";
}
}
}
Instead of
".enabled=false"
use
".disabled=true"
and when condition is satisfied change it to
".disabled=false"
".enabled=false"
use
".disabled=true"
and when condition is satisfied change it to
".disabled=false"
instead of below code
btnUpload.enabled = "true";
write
$('#btnUpload').attr("disa bled", false);
or
$('#btnUpload").removeAttr ibute("dis ables");
you need to call jquery latest javascrit file in head section
btnUpload.enabled = "true";
write
$('#btnUpload').attr("disa
or
$('#btnUpload").removeAttr
you need to call jquery latest javascrit file in head section
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I used this $('#btnUpload").removeAttr ibute("dis abled"); says Unterminated string constraint
ASKER
would this be easier if we use visible ... true/false....
ASKER
how will I get the latest javascript thing..? no idea...
bad combination of single quotes and double quotes.
try this:
$('#btnUpload').removeAttr ibute('dis abled');
try this:
$('#btnUpload').removeAttr
ASKER
tried this says object not supported..$('#btnUpload') .attr("dis abled", false);
ASKER
Microsoft JScript runtime error: Object doesn't support this property or method after your last comment..
If you are not using jQuery, the line above would be (I think, I'm not actually testing this as I type):
document.getElementById("b tnUpload") .removeAtt ribute("di sabled");
document.getElementById("b
ASKER
Microsoft JScript runtime error: 'document.getElementById(. ..)' is null or not an object
Also could try this:
btnUpload.removeAttribute( 'disabled' );
or this:
var thisButton = document.getElementById("b tnUpload") ;
thisButton.removeAttribute ('disabled ');
(Sorry to be spammy with answers... it depends on what you have declared where and whether those things are in scope or not, etc.)
btnUpload.removeAttribute(
or this:
var thisButton = document.getElementById("b
thisButton.removeAttribute
(Sorry to be spammy with answers... it depends on what you have declared where and whether those things are in scope or not, etc.)
Perhaps the issue is your button is id="RadButton" and not "btnUpload" as the previous answers all suggest.
ASKER
no it is btnUpload and I keep getting null value as of the the button, tried your last ex. I get object null error
<telerik:RadButton ID="btnUpload" runat="server" Text="Upload"
onclick="btnUpload_Click" Enabled="false">
<telerik:RadButton ID="btnUpload" runat="server" Text="Upload"
onclick="btnUpload_Click" Enabled="false">
only reason to get that error is that the Id does not match.
When you view source (or inspect w/ Firebug, etc.), what is the button's Id?
When you view source (or inspect w/ Firebug, etc.), what is the button's Id?
ASKER
<table>
<tr>
<td>
<telerik:RadUpload ID="RadUpload1" runat="server" Width="245px" InitialFileInputsCount="1"
MaxFileInputsCount="1" AllowedFileExtensions=".jp g, .tif" OnClientFileSelected="myOn ClientFile Selected">
</telerik:RadUpload>
</td>
<td valign="top">
<telerik:RadButton ID="btnUpload" runat="server" Text="Upload"
onclick="btnUpload_Click" Enabled="false">
</telerik:RadButton>
</td>
</tr>
</table>
here my full code for this...so it is called btnUpload I have no idea why it is null
<tr>
<td>
<telerik:RadUpload ID="RadUpload1" runat="server" Width="245px" InitialFileInputsCount="1"
MaxFileInputsCount="1" AllowedFileExtensions=".jp
</telerik:RadUpload>
</td>
<td valign="top">
<telerik:RadButton ID="btnUpload" runat="server" Text="Upload"
onclick="btnUpload_Click" Enabled="false">
</telerik:RadButton>
</td>
</tr>
</table>
here my full code for this...so it is called btnUpload I have no idea why it is null
ASKER
this is in master page.. maybe that's why?
ASKER
found this answer but dont actually know how to implement that because when I put this function on the master page, it complains because I dont have button like that...
http://stackoverflow.com/questions/5886617/disable-button-on-masterpage-net-4-0-c
http://stackoverflow.com/questions/5886617/disable-button-on-masterpage-net-4-0-c
What does "View Source" show for the element you are trying to enable?
JavaScript runs on the client, not the server.
To debug the JavaScript error, it is best to look at the rendered code - what you see when you "View Source". Once you see what the error is, you can then either adjust your server side code to make it match what your JS is trying to do or change your JS to match what your server-side code is creating.
JavaScript runs on the client, not the server.
To debug the JavaScript error, it is best to look at the rendered code - what you see when you "View Source". Once you see what the error is, you can then either adjust your server side code to make it match what your JS is trying to do or change your JS to match what your server-side code is creating.
ASKER
I am attaching view source.. I have even tried this without master page still getting null value for my btnUpload.... arrgghhh.. drives me crazy.
test.txt
test.txt
ASKER
figured it out different by just adding <div> and control that way.. Thank you all for trying to help!