dylanone
asked on
Using @' and getting CS1003: Syntax error, '"' expected
Does anyone see why this line below:
<fc:ConnectDisplay isvisible="<%# (((Publication) Container.DataItem).Title != @'no title')%>" runat="server">
would give this error:
Compiler Error Message: CS1003: Syntax error, '"' expected
<fc:ConnectDisplay isvisible="<%# (((Publication) Container.DataItem).Title != @'no title')%>" runat="server">
would give this error:
Compiler Error Message: CS1003: Syntax error, '"' expected
ASKER
I actually had tried that - initially - I get with the above:
The server tag is not well formed.
The server tag is not well formed.
oh is 'no title' a field in the database or something? if so try this isvisible='<%# Eval("no title")%>' .. are you trying to get it to return true or false? If you are, then you want to disallow nulls in the DB or write a function that checks for them before writing the true/false here: isvisible='<%# isNullFunction(Eval("no title"))%>'
ASKER
'no title' is text data that is appearing - and I'm trying to not get it to display.
ok then instead of using isNullFunction, make a isTitleFunction that tests for null, none, or exists then return true or false
isvisible='<%# isTitleFunction(((Publicat ion) Container.DataItem).Title) >'
isvisible='<%# isTitleFunction(((Publicat
The string delimiter is " not '
So it should be
"no title"
rather than
'no title'
shouldn't it?
(Though this isn't winforms, which is my world, so maybe that's tosh)
So it should be
"no title"
rather than
'no title'
shouldn't it?
(Though this isn't winforms, which is my world, so maybe that's tosh)
ASKER
So I wrote a simple - isTitleFunction below and I'm getting an odd error:
CS0030: Cannot convert type 'void' to 'bool'
which is this line that was added yesterday:
<fc:ConnectDisplay isvisible='<%# isTitleFunction(((Publicat ion) Container.DataItem).Title) %>' runat="server">
<script language=C# runat=server>
public void isTitleFunction(string e)
{
if(e != null)
{
e.Replace("no title","");
}
}
</script>
CS0030: Cannot convert type 'void' to 'bool'
which is this line that was added yesterday:
<fc:ConnectDisplay isvisible='<%# isTitleFunction(((Publicat
<script language=C# runat=server>
public void isTitleFunction(string e)
{
if(e != null)
{
e.Replace("no title","");
}
}
</script>
the type should be object and not string..it may be trying to cast an null to a string which throw an error.... try object e instead of string e... test for null then if it is not null then test the value.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Good grief with all the above I get:
System.InvalidCastExceptio n: Specified cast is not valid.
The line below is what is states is the culprit:
<fc:ConnectDisplay isvisible='<%# isTitleFunction(((Publicat ion) Container.DataItem).Title) %>' runat="server">
System.InvalidCastExceptio
The line below is what is states is the culprit:
<fc:ConnectDisplay isvisible='<%# isTitleFunction(((Publicat
take out (publication) thats the only casting???? i dunno.
ASKER
It needs the publication because otherwise it can't find the Title
Compiler Error Message: CS0117: 'object' does not contain a definition for 'Title'
<fc:ConnectDisplay isvisible='<%# isTitleFunction((Container .DataItem) .Title)%>' runat="server">
I'll play with it more tomorrow - if I still don't have it - I'll just give you the points - this appears to be one that could go on for a while but I think we're close.
Compiler Error Message: CS0117: 'object' does not contain a definition for 'Title'
<fc:ConnectDisplay isvisible='<%# isTitleFunction((Container
I'll play with it more tomorrow - if I still don't have it - I'll just give you the points - this appears to be one that could go on for a while but I think we're close.
ASKER
Thanks - I never got this one working 100% correctly but at least I have several ideas now!
<fc:ConnectDisplay isvisible='<%# (((Publication) Container.DataItem).Title != @'no title')%>' runat="server">