|
-
Aug 24th, 2006, 04:08 PM
#1
Thread Starter
Hyperactive Member
Code behind variable in html control attribute problem
I have a boolean in my code behind that I want to control the visibility of a control but I get a databinding error. Not sure if my syntax is correct.
I've simplified what I am doing below. I have no problem accessing public and protected variables in html via <%=whatever%> but when I try to apply to a control attribute it isn't working.
VB Code:
Protected myBoolean as boolean=false
<html>
<Component:myComponent Visible="<%# myBoolean%>"/>
</html>
Truly, you have a dizzying intellect.
-
Aug 24th, 2006, 04:28 PM
#2
Fanatic Member
Re: Code behind variable in html control attribute problem
I'll take a shot at this. I think the reason might be that the control wants a string, not a boolean value.
Try doing this:
Code:
Protected myBoolean as String = "false"
<html>
<Component:myComponent Visible="<%= myBoolean%>"/>
</html>
Let me know!
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Aug 24th, 2006, 04:30 PM
#3
Thread Starter
Hyperactive Member
Re: Code behind variable in html control attribute problem
Tried that one to
Error is:
<%=myBoolean%> is not a valid value for Boolean
Truly, you have a dizzying intellect.
-
Aug 25th, 2006, 08:22 AM
#4
Re: Code behind variable in html control attribute problem
Me.MyControl.Visible = myBoolean
-
Aug 25th, 2006, 04:12 PM
#5
Thread Starter
Hyperactive Member
Re: Code behind variable in html control attribute problem
Where are talking the HTML side of things
Truly, you have a dizzying intellect.
-
Aug 28th, 2006, 11:42 AM
#6
Fanatic Member
Re: Code behind variable in html control attribute problem
I would do it in the codebehind, but you could try this:
<html>
<Component:myComponent Visible="<%= myBoolean.toString %>"/>
</html>
No idea if this works, never do it this way.
-
Aug 29th, 2006, 10:43 AM
#7
Re: Code behind variable in html control attribute problem
 Originally Posted by gtilles
Where are talking the HTML side of things
What I've shown is the same thing, only it's the proper way to facilitate separation of UI and UI logic.
-
Aug 30th, 2006, 10:59 AM
#8
Thread Starter
Hyperactive Member
Re: Code behind variable in html control attribute problem
Thanks but....my question was doing it on the HTMl side not how to do it on the code behind. I am already aware of how to do it on the code-behind.....but in this case, proper coding or not...I want it on the HTML.
This is the question. not looking for alternate answers.
Truly, you have a dizzying intellect.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|