Hello guys, I wonder if you could kindly explain this to me.
Basically, I've got a form and a thank you message above it, here they are:
<asp:Content ID="Content5" ContentPlaceHolderID="contentPlaceholder" Runat="Server">
<div class="thankYouMsg" id="thankYouMsg" runat="server">
<h2>Thank you for your feedback.</h2>
</div>
<div class="contactForm" id="contactForm" runat="server">
<h2>Contact me</h2>
<div class="form" runat="server">
<div class="control-group">
<label class="control-label" for="title">Title</label>
<div class="controls">
<select id="title" runat="server">
<option>Select</option>
<option>Mr</option>
<option>Ms</option>
<option>Miss</option>
<option>Mrs</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">Name</label>
<div class="controls">
<input runat="server" type="text" id="name" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<%--<input id="email" runat="server" type="text" />--%>
<asp:TextBox ID="email" runat="server"></asp:TextBox>
</div>
</div>
<div class="control-group">
<label class="control-label" for="enquiry">Enquiry<span>*</span></label>
<div class="controls">
<textarea id="enquiry" runat="server" type="text"></textarea>
<%--<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>--%>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please enter your message" ControlToValidate="enquiry"></asp:RequiredFieldValidator>
</div>
</div>
<div class="submitButton">
<input id="submitForm" type="submit" value="Submit" runat="server" onserverclick="submitData">
<div class="clear"></div>
</div>
</div>
</div>
</asp:Content>
The form is display:block;
and the thank you message display:none;
when you first land onto the page. What I wanted to do was to, upon form submission, display the thank you message and hide the form. well, it wasn't that obvious/easy I have to say and after quite a bit of research and tries,here is the method I used to achieve that, but I'm not convinced it's the best one:
protected void submitData(object sender, EventArgs e) {
...
//hide form and show thank you message
contactForm.Attributes.Add("class", contactForm.Attributes["class"] + " hidden");
thankYouMsg.Attributes.Add("class", thankYouMsg.Attributes["class"] + " active");
}
Right, why did I do that (and please note the space between the " and the hidden/active string otherwise I will end up with something like contactFormhidden and thankYouMsgactive). Well, because if I do it in any other way, my existing classes gets wiped out and my css rules - here for reference - won't work anymore:
.content .contactForm.hidden{
display:none;
}
.content .thankYouMsg{
display:none;
}
.content .thankYouMsg.active{
display:block;
}
I give you that I'm a real beginner still, so maybe I'm missing something (and I don't want to use a darn Panel asp container by the way!)
Is there a better way rather than having to do this + " hidden"
??!!
thanks