Data binding etc

  • Thread starter Thread starter AAaron123
  • Start date Start date
A

AAaron123

Someone spent much time helping me with this and I thought I understood but
now find I'm not sure abut some things.



I'd appreciate it if you would comment on all or some of the following.



MUST DO IT THIS WAY

<asp:CheckBox Checked='<%# Bind("IsPublic") %>'...

OR COULD DO THIS

<asp:CheckBox Checked="<%# Bind('IsPublic') %>"...

WHICH IS BETTER?



THESE ARE OK??

<input type="button" onclick="window.location.href = 'UserInfo.aspx'"...

<input type="button" onclick="window.location='<%=FromWhoPhoto%>';" ...

RUNAT SERVER NOT REQUIRED BECAUSE OF <%= ?

RUNAT SERVER SEEMS TO BE IMPLIED (these works ok)

SAME FOR <%# ?



THIS IS OK (seems to work)

onclick="window.location.href='<%# "Events_edit.aspx?Action=Delete&id=" &
truncate(Eval("id")) %>'" />

BUT THIS IS NOT OK

text="some-text-here '<%#truncate(Eval("id")) %>'" />
 
Mark Rae said:
Neither is better. Sometimes single quotes are needed because of other
strings / double quotes in the markup.



runat="server" tells ASP.NET makes the control available server-side. It's
required for WebControls, optional for HtmlControls. The <%...%> syntax
tells ASP.NET to run whatever it finds between the two delimiters
server-side - the HtmlControl itself doesn't need to be run server-side
for this. It's normally used to inject text into a control's markup.

BTW, posting in all upper case is considered bad netiquette BECAUSE IT
LOOKS LIKE YOU'RE SHOUTING!!!!!



I used the upper case to try to make it easier to separate my questions from
the markup.

I agree it does look like shouting.

Is it still better to use plain text rather than HTML format (which would
enable other options)?

Thanks
 
Mark Rae said:
Many people have their newsreader configured to filter out HTML posts, and
also posts containing binary attachments...
Is this OK? I think I was told that it is not (I may have misunderstood)
but, if ASP.NET simply runs the functions an places the resultant string
there, it looks like it should be OK.
text="some-text-here '<%#truncate(Eval("id")) %>'" />

Thanks a lot
 
Mark Rae said:
It looks OK...

What happened when you tried it...?

I don't remember - it was a while ago and I had problems that may or may not
have be related to this.
Anyway, I was told (as I understood it at the time) not to do it.
If it is not violating some rule I'll try it again.
I'm also collecting facts from the Internet but they are all bits and
pieces.
No comprehensive set of rules.

Thanks
 
Back
Top