Hello there. I have created a new div inside another div in asp.net. Now I want to use the innerhtml property of that newly created div. I can't find a way..
This is what im doing in my .aspx page..
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="forNewEmployee" runat="server"></div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="link" EventName="click" />
</Triggers>
</asp:UpdatePanel>
<div class="addMore">
<asp:Button ID="link" CssClass="label" runat="server" Text="Add More - Image"
onclick="link_Click" />
</div>
and in codebehind file..
protected void link_Click(object sender, EventArgs e)
{
if (clickCheck != 0)
{
// access the newly generated div 'forNewEmployee' + specific id and call its innerHtml Method?
System.Web.UI.HtmlControls.HtmlControl div = (System.Web.UI.HtmlControls.HtmlControl)ScriptManager1.FindControl("forNewEmployee" + clickCheck);
}
else {
this.forNewEmployee.InnerHtml = newRow();
}
}
I have a function in which I'm building the string to introduce new elements inside the forNewEmployee div. This is how it is defined..
protected string newRow() {
// check for click
clickCheck++;
// check for new row
countForEmployee++;
// building our new row
rowString.AppendLine("<label for='empName" + countForEmployee.ToString() + "'>Your Employee Name: <span>(required)</span></label>");
rowString.AppendLine("<input id='empName" + countForEmployee.ToString() + "' class='registrationformEmployeeText' />");
rowString.AppendLine("</div>");
rowString.AppendLine("<div id='forNewEmployee" + countForEmployee.ToString() + "' name='forNewEmployee" + countForEmployee.ToString() + "' runat='server'></div>");
return rowString.ToString();
}
I'm not entirely sure you can do it with
div
but sure you can do it withasp:Panel
: