Whats wrong with this code"

A

active

<%@ Master Language="VB" CodeFile="Default.master.vb"
Inherits="Default_master" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head id="Head1" runat="server">

<title></title>

function resizeImg(o)

{

var p=o.parentElement;

if ((o.clientWidth/o.clientHeight)>(p.clientWidth/p.clientHeight))

{o.style.width='100%';o.style.height=''}

else

{o.style.width='';o.style.height='100%'}

}



--%>

</script>

</head>

<body style...

....

<asp:TableCell runat="server" ID="TableCellR4C1" Height="300"
BorderStyle="Groove">





<asp:Image ID="Image1" runat="server" AlternateText="Alternate Image"
ImageAlign="Middle"

ImageUrl="~/Images/mydefault.jpg" OnLoad="resizeImg(Image1)" Width="100%"

Height="100%" />





</asp:TableCell>



I get th error message:

'resizeImg' is not a member of 'ASP._default_master'
 
M

Masudur

<%@ Master Language="VB" CodeFile="Default.master.vb"
Inherits="Default_master" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head id="Head1" runat="server">

<title></title>

function resizeImg(o)

{

var p=o.parentElement;

if ((o.clientWidth/o.clientHeight)>(p.clientWidth/p.clientHeight))

{o.style.width='100%';o.style.height=''}

else

{o.style.width='';o.style.height='100%'}

}

--%>

</script>

</head>

<body style...

...

<asp:TableCell runat="server" ID="TableCellR4C1" Height="300"
BorderStyle="Groove">

<asp:Image ID="Image1" runat="server" AlternateText="Alternate Image"
ImageAlign="Middle"

ImageUrl="~/Images/mydefault.jpg" OnLoad="resizeImg(Image1)" Width="100%"

Height="100%" />

</asp:TableCell>

I get th error message:

'resizeImg' is not a member of 'ASP._default_master'


hi...

i dont see any start of script block.... just see a ending block "</
script>"
javascript function should be inside a script block

<script language="javascript" type="text/javascript">
function resizeImg(o)
{
}
</script>

what what is " --%> " ???


Thanks
Masudur
http://munnacs.110mb.com
 
G

Guest

OnLoad represents a server-side function, not a client-side JS. So, make sure
you have defined the function in question in the code-behind of your page.
 
A

active

I deleted some comments when I posed this and must have deleted the line I
added below

Should I be using jscript or JavaScript

thanks




<script type="text/JavaScript" language="JavaScript">
 
G

Guest

On the server side: Image1.Attributes.Add ("onclick", "resizeImg('" +
Image1.ClientID + "')");

Also, modify resizeImg() JS function to include the following as the first
line (before var p = o.parentElement):

var o = document.getElementById(o);
 
A

active

Siva M said:
On the server side: Image1.Attributes.Add ("onclick", "resizeImg('" +
Image1.ClientID + "')");

I don't know where to put the above.

Thanks for helping
 
A

active

I did this and at least do not get any new errors - but I still get:
'resizeImg' is not a member of 'ASP._default_master'

thanks again

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

Image1.Attributes.Add("onclick", "resizeImg('" + Image1.ClientID + "')")

End Sub

and



<script language="JavaScript" type="text/JavaScript">

function resizeImg(o) {

var o = document.getElementById(o);

var p=o.parentElement;

if ((o.clientWidth/o.clientHeight)>(p.clientWidth/p.clientHeight))

{o.style.width='100%';o.style.height=''}

else

{o.style.width='';o.style.height='100%'}

}

--%> </script>





and





<asp:TableCell runat="server" ID="TableCellR4C1" Height="300"
BorderStyle="Groove">





<asp:Image ID="Image1" runat="server" AlternateText="Alternate Image"
Height="100%"

ImageAlign="Middle" ImageUrl="~/Images/churchdefault.jpg" OnLoad="resizeImg"

Width="100%" />


</asp:TableCell>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top