|
I am working on a website that is built in C# MVC. The page i am working on has a datatable and sorting and pagination. The bug is when i click on the Next button on the page, it displays an error asking me to select a value, although there are values selected in subsequent pages. It wont go to the next page until a value has been selected on the first page. I need help on getting away with this bug.
|
|
|
|
|
I think you would remove <required> in the model
|
|
|
|
|
Remove what in the model? Do you want me to post the code? I am posing this question as I am new to MVC.
|
|
|
|
|
Look in the database DAL, there are private and public members in it.
Most MVC Apps use a database model to describe the database and fields when using Entity Framework. You can say this column is required to write a record.
Also, I think in the Models folder, you can say a field is required for validation, so check there as well. The model tells the view that these fields are required for validation.
Technically, makes no sense to me why you would want the user to leave the page without filling in the form first, unless it's a search box or something, and the user has no interest in searching, and the form submit triggers the validation and postback event, and validation fails.
I'm leaving now so I won't back back till tomorrow, but take a peek around in your app.
Database in VB
<Required>
<StringLength(80)>
<MaxLength(80)>
Public Property LoginID As String
Get
Return mLoginID
End Get
Set(value As String)
mLoginID = value
End Set
End Property
Model in C#
public class RegisterExternalLoginModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
public string ExternalLoginData { get; set; }
}
|
|
|
|
|
Remove the required or validation tag
[Required] or <required>
|
|
|
|
|
I looked into the code but was unable to find the appropriate [Required] or validation tag. The code uses Datatables and the validation is related to that.I am not able to find the connection between the Next button and the validation.
|
|
|
|
|
Show some code in the view for the page.
|
|
|
|
|
'
<script type="text/javascript">
$(function () {
var grid = $('.single-select').DataTable({
'lengthMenu': ['500']
});
$('.single-select tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
$('#Id1').val('');
} else {
grid.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
$('#Id1').val($(this).attr('id'));
}
});
var cId = $('#Id').val();
if (cuId > 0) {
$("#grid.single-select")
.find("[id='" + cId + "']")
.addClass('selected');
}
var dGrid = $("#dSelect").DataTable({
'lengthMenu': ['500']
});
$('# dSelect tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
$('#mId').val('');
} else {
dGrid.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
$('#mId').val($(this).attr('id'));
}
});
|
|
|
|
|
That looks like script that paints the textbox edges or borders red or blue
|
|
|
|
|
<script type="text/javascript">
$(function () {
var s = $(".Step");
var nOS = s.length;
var csIdx = @Model.csIdx;
var cS = s [csIdx];
$('#sCount').val(nOS);
$(cS).fadeIn();
if (csIdx > 0) {
$("button[name='prev']").show();
$("button[name='cancel']").show();
}
if (csIdx < nOS - 1) {
$("button[name='next']").show();
$("button[name='cancel']").show();
}
else {
$("button[name='finish']").show();
}
$("button[name='next'],button[name='finish']").click(function () {
var $step = $(".Step:visible");
var ifError = false;
$step.find("input,textarea,select").each(function () {
if (!$(this).validationEngine('validate')) { ifError = true;
}
});
if (ifError)
return false; });
|
|
|
|
|
That validates the next or finish button, by checking a textarea element, a large place to enter text, and if false I guess, will cancel the buttons. You can remove the function temporary to see if that does the trick; to locate the code you have to modify.
$("button[name='next'],button[name='finish']").click(function () {
|
|
|
|
|
That did work! I commented those lines and the validation was not there.
Now, my situation is, that this handler for next button and the finish button is like a master thing. So, i don't know if i should delete these lines or modify the code. Because if I do this it might affect other pages as well. How can I just disable for the current page.
|
|
|
|
|
Now that its located, you need to decide what to do.
It's there for a reason, so leave it commented out and get back to it later.
|
|
|
|
|
Okay. I appreciate all your help. Thanks!
|
|
|
|
|
|
I have posted the code that I think needs to be changed for this bug. Appreciate your help.
|
|
|
|
|
Good day friends! I was wondering if it is possible to access a datalist item from footertemplate control. When I tried it, it shown object reference not set to an instance. How?
|
|
|
|
|
Its possible. Put debugged in your code to check for NULL causing this exception.
modified 20-Sep-20 21:01pm.
|
|
|
|
|
|
Pls add your code what have you tried?
modified 20-Sep-20 21:01pm.
|
|
|
|
|
Hello All,
I was wondering what's the best way to handle forms in asp.net when dealing with master pages.
The simple thing to do, and it hasn't caused me problems so far, is to just make one <from runat="server"> on the main master page and go from there. Not doing so causes problems when you try to create a seach bar at the top of the master page and then an input form on a child page, for example. But it just feels so ugly.
Thoughts?
|
|
|
|
|
Although you should consider understanding the master pages first. They are used to create a similar layout across pages. So, a search box would definitely go in the master page. Unless you want to write the same HTML across pages, which would even break the DRY rule.
So, you must first check (and consider) where are going to show the HTML content. Search box, logo etc they would go in the master page. To be rendered on all pages, a content or snippet such as a form on contact page would only be on that page. So, putting that form in master page would not be a good act.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Does anybody have any idea about this:-
I have several kinds of file(pdf,html,png) in my d: drive inside a folder . I want to open these files on the browser using anchor tag or any hyperlink control but the url should not display the path like d://Somefolder/File it should be like Localhost:1234/Somefolder/file.
|
|
|
|
|
Hello All,
Can some one plz help me in referring a sample which can create a 64 bit webservice to call a 64 bit interop dll
I havetred to create a webserice using asp.net but by default service is targetting 32 bit only and while loading the interop dll it throwing exception as below,
"System.BadImageFormatException: Could not load file or assembly 'Interop.*****, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."
environemt:
OS: windows 2008 server 64 bit
IDE: VS 2010
Thanks in advance
|
|
|
|
|