Using ToolTip to store data

L

LisaBigJax

I am using a series of checkbox's in a repeater -- (not the
checkboxlist) -- the problem I am encountering is that the checkbox
does not have a value attribute. I tried to add it via the
"InputAttribute" however it doesn't seem to hold state on a postback.

Is there any reason why I can't use the ToolTip attribute of the
CheckBox control to store data? Then retreive it via another page?

Here's a visualization of what I am trying to accomplish.

CHECK YOUR WEBSITE FEATURES
[x] Flash
[x] Streaming Video
[ ] Search Engine Optimization
[ ] Extra-Bandwidth

Because checkbox values only hold "true | false", I'd like to use the
ToolTip attribute to hold the "value" attribute of the selection - like
a listitem in a checkboxlist or value in the radio button.

Are there any drawbacks to this? Browser issues?
 
S

sloan

Huh?

Not to be mean, but that is a complete Hack.


I think what your missing is the "Text" property.


Here is a sample:

===============aspx code


<form id="Form1" method="post" runat="server">
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox id="chkA" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "friendlyname2") %>' Checked='<%#
DataBinder.Eval(Container.DataItem, "isCool") %>'></asp:CheckBox>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "friendlyname1") %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>

== end .aspx code


========== code behind page (in vb.net)


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here




If Not (Page.IsPostBack) Then

Me.Repeater1.DataSource = Me.GetDataSet1()
Me.Repeater1.DataBind()


End If


End Sub






Private Function GetDataSet1() As DataSet
Dim ds As New DataSet

Dim sb As New System.Text.StringBuilder
sb.Append("<?xml version=""1.0""?><items>")


sb.Append("<item>")
sb.Append("<itemid>300</itemid>")
sb.Append("<friendlyname1>Meats</friendlyname1>")
sb.Append("<friendlyname2>MT</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() +
"</time>"))
sb.Append("<isCool>true</isCool>")
sb.Append("</item>")


sb.Append("<item>")
sb.Append("<itemid>100</itemid>")
sb.Append("<friendlyname1>Vegetables</friendlyname1>")
sb.Append("<friendlyname2>VG</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() +
"</time>"))
sb.Append("<isCool>false</isCool>")
sb.Append("</item>")


sb.Append("<item>")
sb.Append("<itemid>200</itemid>")
sb.Append("<friendlyname1>Fruits</friendlyname1>")
sb.Append("<friendlyname2>FR</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() +
"</time>"))
sb.Append("<isCool>true</isCool>")
sb.Append("</item>")



sb.Append("</items>")



Dim ms As New System.IO.MemoryStream
Dim writer As New System.IO.StreamWriter(ms)
writer.Write(sb.ToString())
writer.Flush()
ms.Position = 0
ds.ReadXml(ms)
Return ds
End Function 'GetDataSet1



=== end vb.net code behind






PS

My method for generating a DS is for EXAMPLE's only.
It is not a good way to do it. (Just in case somebody sees this for a
non checkbox question)

...

I am using a series of checkbox's in a repeater -- (not the
checkboxlist) -- the problem I am encountering is that the checkbox
does not have a value attribute. I tried to add it via the
"InputAttribute" however it doesn't seem to hold state on a postback.

Is there any reason why I can't use the ToolTip attribute of the
CheckBox control to store data? Then retreive it via another page?

Here's a visualization of what I am trying to accomplish.

CHECK YOUR WEBSITE FEATURES
[x] Flash
[x] Streaming Video
[ ] Search Engine Optimization
[ ] Extra-Bandwidth

Because checkbox values only hold "true | false", I'd like to use the
ToolTip attribute to hold the "value" attribute of the selection - like
a listitem in a checkboxlist or value in the radio button.

Are there any drawbacks to this? Browser issues?
 
L

LisaBigJax

Actually, I can't use the TEXT attribute because that is dynamically
generated by conectation of several fields - the above example (which I
made up) did not illustrate that.

Anyway, I did solve the problem by adding an sub in the pre-render
event of the Repeater using the InputAttribute.Add("value").

Then I just recalled it via the next page.
checkboxvalue = checkbox.InputAttribute("value")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top