Saturday, March 24, 2012

Newbie: Simple Help

Hello Everyone

I am new to ASP.NET. I need help on converting one line of code , which has been giving me a problem. I tried to add Response.Write () and remove <% %>, but it doesn't work. The line of code is in BOLD.

<script language=vbscript runat=server>

Sub MakeButton(ButtonName, OnClickFunc, IsSelected, UpImage, DownImage, HelpText)
Dim image

If IsSelected Then
image = DownImage
Else
image = UpImage
End If

%>
<IMG src="http://pics.10026.com/?src=<%=image%>" BORDER=0 NAME="<%=ButtonName%>" ONMOUSEDOWN="javascript:<%=OnClickFunc%>('<%=ButtonName%>');" ALT="<%=HelpText%>">
<%

End Sub

</script>

Thanks in advance

btran

ASP.NET doesn't work that way. The way you are doing it is seems to be based around the old ASP Inline style. Try the following:
Sub MakeButton(ButtonName asString, OnClickFunc asString, IsSelected asString, UpImage asString, DownImage asString, HelpText asString)Dim imageIf IsSelectedThen image = DownImageElse image = UpImageEnd IfDim imageObject as HtmlImage = new HtmlImage()imageObject.Alt = HelpTextimageObject.Src = imageimageObject.Name = ButtonNameimageObject.Attributes.Add("onmousedown",String.Format("javascript:{0}('{1}');", OnClickFunc, IsSelected))Me.Controls.Add(imageObject)End Sub
However looking at this code may I suggest that you refactor it so that everything flows in a more object oriented way. This seems very linier in the way you are approaching ASP.NET.

0 comments:

Post a Comment