Add attribute - apparently I have to

  • Thread starter Thread starter Haydnw
  • Start date Start date
H

Haydnw

I have the following line of code in a code-behind file. It's part of a
event which is run when a user clicks an asp:imagebutton on a page.

tblMainImage.Rows[0].Cells[0].Attributes.Add("background",
"../images/albums/" & Request.QueryString("d") & "/" &
RowView("strFilename") & ".jpg")

However, when I view the page I get an error message with this line
highlighted, saying:

'Property access must assign to the property or use its value.'

Am I not assigning to the property with the line I'm using??? I'm adding the
attribute so surely I'm assigning to it? I've looked at lots of past posts
and they all seem to indicate using the syntax above. So where am I going
wrong?! Thanks in advance to anyone who can point me in the right direction.

Haydn
 
Haydnw said:
I have the following line of code in a code-behind file. It's part of a
event which is run when a user clicks an asp:imagebutton on a page.

tblMainImage.Rows[0].Cells[0].Attributes.Add("background",
"../images/albums/" & Request.QueryString("d") & "/" &
RowView("strFilename") & ".jpg")

However, when I view the page I get an error message with this line
highlighted, saying:

'Property access must assign to the property or use its value.'

Am I not assigning to the property with the line I'm using??? I'm adding the
attribute so surely I'm assigning to it? I've looked at lots of past posts
and they all seem to indicate using the syntax above. So where am I going
wrong?! Thanks in advance to anyone who can point me in the right
direction.

Haydn,

Simplify the situation by replacing the attribute value with "x" and see
what happens:

tblMainImage.Rows[0].Cells[0].Attributes.Add("background", "x")
 
I'm a bit confused here - if this is VB.NET code, shouldn't those []
brackets be () ones?

Steve
 
Hi John,

Thanks for the quick response! I had tried something similar, but have just
tried it again with "x" to be on the safe side. I get exactly the same error
(obviously with all my concatenation junk in the first post replaced with
"x").

Any other ideas? :) I'm starting to go out of my mind trying to figure this
one out!!

Cheers,
Haydn



John Saunders said:
Haydnw said:
I have the following line of code in a code-behind file. It's part of a
event which is run when a user clicks an asp:imagebutton on a page.

tblMainImage.Rows[0].Cells[0].Attributes.Add("background",
"../images/albums/" & Request.QueryString("d") & "/" &
RowView("strFilename") & ".jpg")

However, when I view the page I get an error message with this line
highlighted, saying:

'Property access must assign to the property or use its value.'

Am I not assigning to the property with the line I'm using??? I'm adding the
attribute so surely I'm assigning to it? I've looked at lots of past posts
and they all seem to indicate using the syntax above. So where am I going
wrong?! Thanks in advance to anyone who can point me in the right
direction.

Haydn,

Simplify the situation by replacing the attribute value with "x" and see
what happens:

tblMainImage.Rows[0].Cells[0].Attributes.Add("background", "x")
 
Erm...yes. Yes they should.

*Shuffles off into the corner looking sheepish...*

Cheers guys. :)

H



Steve Willcock said:
I'm a bit confused here - if this is VB.NET code, shouldn't those []
brackets be () ones?

Steve

Haydnw said:
I have the following line of code in a code-behind file. It's part of a
event which is run when a user clicks an asp:imagebutton on a page.

tblMainImage.Rows[0].Cells[0].Attributes.Add("background",
"../images/albums/" & Request.QueryString("d") & "/" &
RowView("strFilename") & ".jpg")

However, when I view the page I get an error message with this line
highlighted, saying:

'Property access must assign to the property or use its value.'

Am I not assigning to the property with the line I'm using??? I'm adding the
attribute so surely I'm assigning to it? I've looked at lots of past posts
and they all seem to indicate using the syntax above. So where am I going
wrong?! Thanks in advance to anyone who can point me in the right direction.

Haydn
 
AttributeCollection coll = tblMainImage.Rows[0].Cells[0].Attributes;
coll.Add("background", "x");
--
John Saunders
johnwsaundersiii at hotmail

Haydnw said:
Hi John,

Thanks for the quick response! I had tried something similar, but have just
tried it again with "x" to be on the safe side. I get exactly the same error
(obviously with all my concatenation junk in the first post replaced with
"x").

Any other ideas? :) I'm starting to go out of my mind trying to figure this
one out!!

Cheers,
Haydn



John Saunders said:
Haydnw said:
I have the following line of code in a code-behind file. It's part of a
event which is run when a user clicks an asp:imagebutton on a page.

tblMainImage.Rows[0].Cells[0].Attributes.Add("background",
"../images/albums/" & Request.QueryString("d") & "/" &
RowView("strFilename") & ".jpg")

However, when I view the page I get an error message with this line
highlighted, saying:

'Property access must assign to the property or use its value.'

Am I not assigning to the property with the line I'm using??? I'm
adding
the
attribute so surely I'm assigning to it? I've looked at lots of past posts
and they all seem to indicate using the syntax above. So where am I going
wrong?! Thanks in advance to anyone who can point me in the right
direction.

Haydn,

Simplify the situation by replacing the attribute value with "x" and see
what happens:

tblMainImage.Rows[0].Cells[0].Attributes.Add("background", "x")
 
Back
Top