TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ejazul Haq
NA
23
1.9k
ASP.NET MVC Validation
Jul 24 2017 6:26 AM
validation on back end as well as on front end in ASP.NET MVC
for the feedback rating system as shown in the picture for 2 cases
1 By default one star i seelcted
2 The selection/filling of the star is mandatory
the html code
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<MediCubesPatient.Models.RegIFeedbackQuestion>>" %>
<div class="row">
<div class="col-lg-12">
<form action="/Feedback/GetForm" method="post" id="customerDetailSearchForm">
<div class="table">
<table class="table no-spacing" id="table1">
<thead>
<tr>
</tr>
</thead>
<tbody id="tbody">
<% int i = 1; %>
<input type="hidden" value='<%=Model.Count() %>' name="Count" />
<input type="hidden" value='<%=Model.FirstOrDefault().VisitID %>' name="VisitID" />
<% foreach (var item in Model)
{ %>
<tr>
<td style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 6px;"><%=i %>.</td>
<% if (item.QuestionText != null)
{ %>
<td style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 6px;">
<input type="hidden" value='<%=item.QuestionId %>' name='QuestionId<%=i %>' id='QuestionId<%=i %>' />
<input type="hidden" value='<%=item.FbQTypeId %>' name='FbQTypeId<%=i %>' id='FbQTypeId<%=i %>' />
<input type="hidden" value='<%=item.Viewtype %>' name='Viewtype<%=i %>' id='Viewtype<%=i %>' />
<%=item.QuestionText %><%} %><br />
<% if (item.FbQTypeId != 1)
{%>
<textarea rows="1" id="ResponseText" name='ResponseText<%=i %>' style="margin-bottom: 8px;" required></textarea>
<%} %>
<% else
{ %>
<fieldset class="rating" id='rating<%=i %>' >
<input type="radio" id='star5<%=i %>' class="rating" name='rating<%=i %>' value="5" onclick="getRating(5);" /><label class="full" for='star5<%=i %>' title="Awesome - 5 stars"></label>
<input type="radio" id='star4<%=i %>' class="rating" name='rating<%=i %>' value="4" onclick="getRating(4);" /><label class="full" for='star4<%=i %>' title="Pretty good - 4 stars"></label>
<input type="radio" id='star3<%=i %>' class="rating" name='rating<%=i %>' value="3" onclick="getRating(3);" /><label class="full" for='star3<%=i %>' title="Good - 3 stars"></label>
<input type="radio" id='star2<%=i %>' class="rating" name='rating<%=i %>' value="2" onclick="getRating(2);" /><label class="full" for='star2<%=i %>' title="Average - 2 stars"></label>
<input type="radio" id='star1<%=i %>' class="rating" name='rating<%=i %>' value="1" onclick="getRating(1);" checked /><label class="full" for='star1<%=i %>' title="Fair - 1 star"></label>
</fieldset>
</td>
<%} %>
</tr>
<% i++;%>
<% } %>
</tbody>
</table>
</div>
<button type="submit" class="button" value="Submit" style="float: right">Submit</button>
</form>
</div>
</div>
<script type="text/javascript">
// var rateval;
//function getRating(val) {
// rateval = val;
//};
//$(function () {
// debugger;
// var $radios = $('input:radio[value=1]');
// if ($radios.is(':checked') === false) {
// alert('Checking the star is mandatory');
// $radios.filter('[value=1]').prop('checked', true);
// }
//});
//$(function () {
// debugger;
// alert('Checking the star is mandatory');
//});
</script>
Reply
Answers (
1
)
session timeout
How to show last item of dropdown list in first postion