Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 12, 2012 09:38 PM by bbcompent1
Apr 12, 2012 04:36 PM|LINK
I think the issue is that I am adding contentEditable="true" to an ASP Label which you can't really do.
I've tried doing this:
<h1 id="h1Test" contenteditable="true" runat="server"><asp:Label ID="h1" runat="server" CssClass="intro"></asp:Label></h1>
But I'm not sure how to get the h1Test assigned to a string variable in the code-behind file
Apr 12, 2012 04:45 PM|LINK
A label is not an editable control. use a text box.
Apr 12, 2012 04:50 PM|LINK
contentEditable isn't "supported" by an ASP control. Which is why I think it isn't reading the changed value.
I think it has to be html controls but I'm not sure how I would use them in the code-behind.
Apr 12, 2012 05:07 PM|LINK
Are you trying to change these database values on the fly? If so, you're going to probably need to do an OnTextChanged event for each field. Others here may have other suggestions but without seeing your entire project, I can only fathom a guess.
Apr 12, 2012 06:54 PM|LINK
Okay, this is what I have on my page entitled EditMyContent.aspx
<asp:Button ID="saveBtn" runat="server" Text="Save Changes"
<asp:Image ID="userImage" runat="server" AlternateText="User" CssClass="image"/>
<h1><asp:Label ID="h1" runat="server" CssClass="intro" contentEditable="true"></asp:Label></h1>
And this is everything I have in my saveBtn_Click function in the code-behind
protected void saveBtn_Click(object sender, EventArgs e)
newName = h1.Text;
newIntro = intro.Text;
newEduc = educ.Text;
newWork = employ.Text;
string connectionInfo = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
using (SqlConnection connection = new SqlConnection(connectionInfo))
SqlCommand myCommand = new SqlCommand("UPDATE simpleContent SET userName = @newName, infoContent = @newIntro, educContent = @newEduc, workContent = @newWork WHERE userID = @userName", connection);
string username = HttpContext.Current.User.Identity.Name;
Apr 12, 2012 09:38 PM|LINK
But label is not editable. You have to use a textbox or something like that. Try textbox without that contentEditable tag since textbox is editable by default.