Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 25, 2010 02:38 AM by nv
Member
45 Points
211 Posts
Oct 26, 2009 10:33 AM|LINK
Hi there i am trying to follow the book Apress.Beginning.ASP.NET.E.Commerce.In.C.Sharp.From.Novice.To.Professional with VB.
I am in Chapter 4 and got the first problem:
CssClass='<%# Eval("DepartmentID").ToString() ==
Request.QueryString["DepartmentID"] ? "DepartmentSelected" :
"DepartmentUnselected" %>'>
this works in c# but not in vb, i get this errors:
Error 1 Expression expected. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 4 Error 2 Property access must assign to the property or use its value. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 5 Error 3 Identifier expected. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 5 Error 4 Syntax error. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 6
thanks in advance
All-Star
112231 Points
18268 Posts
Moderator
Oct 26, 2009 11:30 AM|LINK
Look into using If().
Refer: http://blogs.msdn.com/vbteam/archive/2008/03/11/if-operator-a-new-and-improved-iif-sophia-salim.aspx
31382 Points
5424 Posts
Oct 26, 2009 11:33 AM|LINK
insterad of Ternary Operator (?:) use IIF in vb.net
Refer :
http://blog.dmbcllc.com/2007/11/29/the-ternary-operator-in-vbnet/
http://www.panopticoncentral.net/archive/2007/05/08/20433.aspx
CssClass=IIf('<%# Eval("DepartmentID").ToString() ==
Request.QueryString["DepartmentID"]), "DepartmentSelected" ,"DepartmentUnselected" %>')
Participant
1047 Points
275 Posts
Oct 26, 2009 11:34 AM|LINK
http://www.developerfusion.com/tools/convert/csharp-to-vb/
Star
9332 Points
1744 Posts
Oct 26, 2009 11:41 AM|LINK
Hi, That is Ternary operator in C# and syntax will differ in VB. Use IIF CssClass= '<%# IIf(Eval("DepartmentID").ToString() = Request.QueryString("DepartmentID"),"DepartmentSelected", "DepartmentUnselected" %>'
Oct 26, 2009 11:45 AM|LINK
karthicks Request.QueryString["DepartmentID"]
It should be open bracket(Parenthesis) '(', not square bracket'['...
Contributor
2194 Points
308 Posts
Oct 26, 2009 11:50 AM|LINK
Hi,
Also note that "=" is used for comparison not "==" .
3763 Points
858 Posts
Oct 26, 2009 11:56 AM|LINK
try this in VB
CssClass =<%#Eval(IIf(Request.QueryString("DepartmentID"), "DepartmentSelected", "DepartmentUnselected"))%>
Oct 26, 2009 12:49 PM|LINK
thank you all for your replys,
but non of them worked for me.
this is the Datalist: In C# project
<asp:DataList ID="list" runat="server" CssClass="CategoryListContent" Width="200px"> <ItemTemplate> » <asp:HyperLink ID="HyperLink1" Runat="server" NavigateUrl='<%# "../Catalog.aspx?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + Eval("CategoryID") %>' Text='<%# Eval("Name") %>' ToolTip='<%# Eval("Description") %>' CssClass='<%# Eval("CategoryID").ToString() == Request.QueryString["CategoryID"] ? "CategorySelected" : "CategoryUnselected" %>'>> </asp:HyperLink> « </ItemTemplate> <HeaderTemplate> Choose a Category </HeaderTemplate> <HeaderStyle CssClass="CategoryListHead" /> </asp:DataList>
when i tryed the iif i got this error:
Error 2 The server tag is not well formed. ./CategoriesList.ascx 5
12685 Points
2005 Posts
ASPInsiders
MVP
Oct 26, 2009 12:59 PM|LINK
I believe the following will work:
CssClass='<%# if(Eval("DepartmentID").ToString() = Request.QueryString("DepartmentID"), "DepartmentSelected","DepartmentUnselected") %>'>
bexasp
Member
45 Points
211 Posts
Convert C# to VB
Oct 26, 2009 10:33 AM|LINK
Hi there i am trying to follow the book Apress.Beginning.ASP.NET.E.Commerce.In.C.Sharp.From.Novice.To.Professional with VB.
I am in Chapter 4 and got the first problem:
CssClass='<%# Eval("DepartmentID").ToString() ==
Request.QueryString["DepartmentID"] ? "DepartmentSelected" :
"DepartmentUnselected" %>'>
this works in c# but not in vb, i get this errors:
Error 1 Expression expected. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 4
Error 2 Property access must assign to the property or use its value. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 5
Error 3 Identifier expected. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 5
Error 4 Syntax error. c:\inetpub\wwwroot\UserControls\DepartmentsList.ascx 6
thanks in advance
MetalAsp.Net
All-Star
112231 Points
18268 Posts
Moderator
Re: Convert C# to VB
Oct 26, 2009 11:30 AM|LINK
Look into using If().
Refer: http://blogs.msdn.com/vbteam/archive/2008/03/11/if-operator-a-new-and-improved-iif-sophia-salim.aspx
karthicks
All-Star
31382 Points
5424 Posts
Re: Convert C# to VB
Oct 26, 2009 11:33 AM|LINK
insterad of Ternary Operator (?:) use IIF in vb.net
Refer :
http://blog.dmbcllc.com/2007/11/29/the-ternary-operator-in-vbnet/
http://www.panopticoncentral.net/archive/2007/05/08/20433.aspx
CssClass=IIf('<%# Eval("DepartmentID").ToString() ==
Request.QueryString["DepartmentID"]), "DepartmentSelected" ,"DepartmentUnselected" %>')
Karthick S
net.hitesh
Participant
1047 Points
275 Posts
Re: Convert C# to VB
Oct 26, 2009 11:34 AM|LINK
http://www.developerfusion.com/tools/convert/csharp-to-vb/
.net Developer
fayaz_3e
Star
9332 Points
1744 Posts
Re: Convert C# to VB
Oct 26, 2009 11:41 AM|LINK
Hi,
That is Ternary operator in C# and syntax will differ in VB. Use IIF
CssClass= '<%# IIf(Eval("DepartmentID").ToString() =
Request.QueryString("DepartmentID"),"DepartmentSelected",
"DepartmentUnselected" %>'
fayaz_3e
Star
9332 Points
1744 Posts
Re: Convert C# to VB
Oct 26, 2009 11:45 AM|LINK
It should be open bracket(Parenthesis) '(', not square bracket'['...
ratish_shriy...
Contributor
2194 Points
308 Posts
Re: Convert C# to VB
Oct 26, 2009 11:50 AM|LINK
Hi,
Also note that "=" is used for comparison not "==" .
devensawant
Contributor
3763 Points
858 Posts
Re: Convert C# to VB
Oct 26, 2009 11:56 AM|LINK
try this in VB
CssClass =<%#Eval(IIf(Request.QueryString("DepartmentID"), "DepartmentSelected", "DepartmentUnselected"))%>If my post helps you then please mark as answer
bexasp
Member
45 Points
211 Posts
Re: Convert C# to VB
Oct 26, 2009 12:49 PM|LINK
thank you all for your replys,
but non of them worked for me.
this is the Datalist: In C# project
<asp:DataList ID="list" runat="server" CssClass="CategoryListContent" Width="200px"> <ItemTemplate> » <asp:HyperLink ID="HyperLink1" Runat="server" NavigateUrl='<%# "../Catalog.aspx?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + Eval("CategoryID") %>' Text='<%# Eval("Name") %>' ToolTip='<%# Eval("Description") %>' CssClass='<%# Eval("CategoryID").ToString() == Request.QueryString["CategoryID"] ? "CategorySelected" : "CategoryUnselected" %>'>> </asp:HyperLink> « </ItemTemplate> <HeaderTemplate> Choose a Category </HeaderTemplate> <HeaderStyle CssClass="CategoryListHead" /> </asp:DataList>when i tryed the iif i got this error:
Error 2 The server tag is not well formed. ./CategoriesList.ascx 5
docluv
Star
12685 Points
2005 Posts
ASPInsiders
MVP
Re: Convert C# to VB
Oct 26, 2009 12:59 PM|LINK
I believe the following will work:
CssClass='<%# if(Eval("DepartmentID").ToString() = Request.QueryString("DepartmentID"), "DepartmentSelected","DepartmentUnselected") %>'>