W
Wade
Hi all,
Question regarding server controls. I have built a server control that
creates two listboxes and a few buttons. Here's a snippet to show how I've
done this (from AddAttributesToRender sub):
' Available listbox
writer.AddAttribute(HtmlTextWriterAttribute.Class,
AvailableListbox_Class)
writer.AddAttribute(HtmlTextWriterAttribute.Size,
Convert.ToString(AvailableListbox_Size))
writer.AddAttribute(HtmlTextWriterAttribute.Style, "width:" &
Convert.ToString(AvailableListbox_Width) & ";")
writer.RenderBeginTag(HtmlTextWriterTag.Select)
writer.RenderEndTag()
' Add all items button
writer.AddAttribute(HtmlTextWriterAttribute.Class,
AddAllItems_Class)
writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
Page.GetPostBackEventReference(Me, "AddAllItems"))
writer.AddAttribute(HtmlTextWriterAttribute.Style, "width:" &
Convert.ToString(AddAllItems_Width) & ";")
writer.RenderBeginTag(HtmlTextWriterTag.Button)
writer.Write(AddAllItems_Text)
writer.RenderEndTag()
I have an issue -- I'd like to also pass in a connection string and stored
procedure name to the server control (this is not a problem) and build a
datatable (also not a table) to bind to the listbox (the problem). I don't
know how to appropriately bind my data to the listbox.
Is there anyway to build a dynamic control (i.e. listbox) and then add it to
a placeholder or something that gets rendered from my server control, rather
than using the "writer.RenderBeginTag(HtmlTextWriterTag.Select"? The only
way I can see myself doing this is populating the datatable, and then
creating a for next loop in the between the Begin/End tag of my listbox.
Any suggestions or ideas? Ideally I'd like to take my dynamic listbox,
which is already bound to my datatable, and have it just render!
Thanks,
Wade
Question regarding server controls. I have built a server control that
creates two listboxes and a few buttons. Here's a snippet to show how I've
done this (from AddAttributesToRender sub):
' Available listbox
writer.AddAttribute(HtmlTextWriterAttribute.Class,
AvailableListbox_Class)
writer.AddAttribute(HtmlTextWriterAttribute.Size,
Convert.ToString(AvailableListbox_Size))
writer.AddAttribute(HtmlTextWriterAttribute.Style, "width:" &
Convert.ToString(AvailableListbox_Width) & ";")
writer.RenderBeginTag(HtmlTextWriterTag.Select)
writer.RenderEndTag()
' Add all items button
writer.AddAttribute(HtmlTextWriterAttribute.Class,
AddAllItems_Class)
writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
Page.GetPostBackEventReference(Me, "AddAllItems"))
writer.AddAttribute(HtmlTextWriterAttribute.Style, "width:" &
Convert.ToString(AddAllItems_Width) & ";")
writer.RenderBeginTag(HtmlTextWriterTag.Button)
writer.Write(AddAllItems_Text)
writer.RenderEndTag()
I have an issue -- I'd like to also pass in a connection string and stored
procedure name to the server control (this is not a problem) and build a
datatable (also not a table) to bind to the listbox (the problem). I don't
know how to appropriately bind my data to the listbox.
Is there anyway to build a dynamic control (i.e. listbox) and then add it to
a placeholder or something that gets rendered from my server control, rather
than using the "writer.RenderBeginTag(HtmlTextWriterTag.Select"? The only
way I can see myself doing this is populating the datatable, and then
creating a for next loop in the between the Begin/End tag of my listbox.
Any suggestions or ideas? Ideally I'd like to take my dynamic listbox,
which is already bound to my datatable, and have it just render!
Thanks,
Wade