Saving values from User Control to database
Posted on 2012-03-21
I have a user control that has two textboxes
<td align="right" >Select Question Color:</td>
<td ><asp:TextBox ID="txtquestioncolor" class="color" value="ffffff" runat="server" /></td>
<td align="right">Select Font Color:</td>
<td ><asp:TextBox ID="txtfontcolor" class="color" value="66ff00" runat="server" /></td>
The page that uses this control has a reference to the usercontrol:
<%@ Register src="~/UserControls/ColorPicker_03.ascx" tagname="ColorPicker_03" tagprefix="uc1" %>
and is called here:
<uc1:ColorPicker_03 ID="colorpicker1" runat="server" />
The user will see a page where, among other things, are able to select two colors. I need to save the colors selected to my database.
I have a Save function in the code behind like so that is saving to a class
Question.Question = txtQuestion.Text
Question.ShortDesc = txtShrtDesc.Text.Trim()
Question.PrintDesc = txtPrintDesc.Text.Trim()
Question.QuestionColor = txtquestioncolor.Text
Question.FontColor = txtfontcolor.Text
Before I put the color text boxes into a user control, I was able to save the values of txtquestioncolor and txtfontcolor. Now those two text boxes are empty.
My question is how do I read the values from the two text boxes on the user control?