Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Javascript Code:

C#
function uploadComplete(sender, args) {

           //   var imgDisplay = $get("imgDisplay");
           var imgDisplay = $('.imgDisplay');
           //    imgDisplay.src = "images/async.gif";
           var img = new Image();
           img.onload = function () {

               imgDisplay.style.cssText = "height:50px;width:50px";
               imgDisplay.src = img.src;
           };
           img.src = "<%=ResolveUrl(UploadFolderPath) %>" + args.get_fileName();
       }


this function give me the error:Javascript runtime error:unable to set css Text property of undefined or null reference

Tell me whats the problem.and how can i solve this problem
Thanks in advance
Posted
Comments
Naz_Firdouse 23-Jul-13 1:51am    
the error clearly mentions that the variable imgDisplay is null or undefined.
So make sure that when you call var imgDisplay = $('.imgDisplay'); you are getting value for the variable
RahulRana723 23-Jul-13 4:18am    
imgDisplay is not null.it says that imgDisplay.style is null.when i debug the code
Joezer BH 23-Jul-13 4:39am    
This is strange indeed, what is the element imgDisplay?
Naz_Firdouse 23-Jul-13 4:49am    
post your design code as well...
Joezer BH 23-Jul-13 1:55am    
Try adding a semicolon at the end of your css text line
imgDisplay.style.cssText = "height:50px;width:50px ; ";

The whole wrapper object returned by the selector $('.imgDisplay') could be null. Please check it up. Please see:
http://api.jquery.com/category/selectors/[^].

The selected element could be not found. You tried to use the class selector, http://api.jquery.com/class-selector/[^].

Make sure the class "imgDisplay" really exist and is used in the attribute of some element(s): class="imgDisplay", without dot. Or use some other, correct selector(s).

—SA
 
Share this answer
 
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Jul-13 10:05am    
The problem is: I think OP already have this information. It won't resolve the problem of null. I think the error indicates that the whole wrapper object is null. Please see my answer.
—SA
try this
$('.imgDisplay').attr('style', 'height:50px;width:50px');
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900