|
I do lot fo work by javascript on web page (like validation , enable and disable textbox ,changes the value of label) and when we do a postback by buttonclick all work done by java script is lost , pls suggest how to do this asap.
Thanks
|
|
|
|
|
|
Write a program to create ‘Employee’ class with id, name non-static members and employeeCounter as Static data member. Accept id, name values from user (using Console.ReadLine() method) and assign them to Employee data members. Count how many objects created for Employee class, display the content using Console application.
|
|
|
|
|
|
This looks like homework
modified 20-Sep-20 21:01pm.
|
|
|
|
|
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.
|
|
|
|