|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
I want to be able to reload my Datatable once my checkbox is clicked , provided below is my attempted code but I continue to get error:Uncaught TypeError: Cannot set property 'data' of null not really sure how to handle this error. I have provided both the javascript and the view in my MVC application please let me know if you need more details.
.js
function ReloadTable()
{
$(document).ready(function () {
var table = $('#DashboardTable').DataTable({
"processing": true, // for show progress bar
"serverSide": true, // for process server side
"filter": true, // this is for disable filter (search box)
"orderMulti": false, // for disable multiple column at once
//"pageLength": 5,
"ajax": {
"url": "/Chargeback/Index",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "ChargebackCode" },
{ "data": "StatusName" },
{ "data": "BusinessUnitName" },
{ "data": "InvoiceCode" },
{ "data": "OrderCode" },
{ "data": "PickTicketCode" },
{ "data": "CustomerPo" },
{ "data": "AssignedDepartment" },
{ "data": "DivisionName" },
{ "data": "Customer" },
{ "data": "WarehouseName" },
{ "data": "Coordinator" },
{ "data": "ChargebackDate" },
{ "data": "ModDate" },
{ "data": "ChargebackDeadline" },
{ "data": "ChargebackCloseDate" },
{ "data": " DaysOpen" },
{ "data": "ChargebackAmount" },
{ "data": "ChargebackBalance" },
{ "data": "FaultName" },
{ "data": "ResponsibleName" }
]
});
table.ajax.reload();
});
}
View
@using (Html.BeginForm("Index", "Chargeback"))
{
<label id = "Include" > @Html.CheckBox("IncludeClosed", (bool)ViewBag.IncludeClosed, new { onChange = "ReloadTable()" }) Include Closed</label>
<table id="DashboardTable" class="table table-striped" >
<thead>
<tr>
<th>Code</th>
<th>Status</th>
<th>Business</th>
<th>Invoice</th>
<th>Order</th>
<th>Pick Tickets</th>
<th>Customer PO</th>
<th>Assigned</th>
<th>Division</th>
<th>Customer</th>
<th>Warehouse</th>
<th>Coordinator</th>
<th>Open Date</th>
<th>Last Activity</th>
<th>Deadline</th>
<th>Closed Date</th>
<th>Days Open</th>
<th>Amount</th>
<th>Balance</th>
<th>Fault</th>
<th>Responsible</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
var chargebackDeadline = item.ChargebackDeadline == null ? "" : ((DateTime)item.ChargebackDeadline).ToString("MM/dd/yyyy");
var chargebackCloseDateAsString = item.ChargebackCloseDate == null ? "" : ((DateTime)item.ChargebackCloseDate).ToString("MM/dd/yyyy");
<tr>
<td>@Html.ActionLink(item.ChargebackCode, "Details", "Chargeback", new { id = item.Id }, null)</td>
<td>@item.StatusName</td>
<td>@item.BusinessUnitName</td>
<td>@item.InvoiceCode</td>
<td>@item.OrderCode</td>
<td>@item.PickTicketCode</td>
<td>@item.CustomerPo</td>
<td>@item.AssignedDepartment</td>
<td>@item.DivisionName</td>
<td>@item.Customer</td>
<td>@item.WarehouseName</td>
<td>@item.Coordinator</td>
<td>@item.ChargebackDate.ToString("MM/dd/yyyy")</td>
<td>@item.ModDate.ToString("MM/dd/yyyy")</td>
<td>@chargebackDeadline</td>
<td>@chargebackCloseDateAsString</td>
<td>@item.DaysOpen</td>
<td>[email protected]</td>
<td>[email protected]</td>
<td>@item.FaultName</td>
<td>@item.ResponsibleName</td>
</tr>
}
</tbody>
</table>
}
|
|
|
|
|
How to perform ajax on Data-table once I click on the check-box.
I already have the ability to auto post-back once the checkbox is clicked, I'm not sure how to achieve this.
View:
<script>
$(document).ready(function () {
$("#DashboardTable").DataTable({
"processing": true,
"serverSide": true,
"filter": true,
"orderMulti": false,
"pageLength": 5,
"ajax": {
"url": "/Chargeback/Index",
"type": "GET",
"datatype": "json"
},
"columnDefs":
[{
"targets": [0],
"visible": false,
"searchable": false
},
{
"targets": [7],
"searchable": false,
"orderable": false
},
{
"targets": [8],
"searchable": false,
"orderable": false
},
{
"targets": [9],
"searchable": false,
"orderable": false
}],
"columns": [
{"data":"ChargebackCode"},
{"data":"StatusName"},
{"data":"BusinessUnitName"},
{"data":"InvoiceCode"},
{"data":"OrderCode"},
{"data":"PickTicketCode"},
{"data":"CustomerPo"},
{"data":"AssignedDepartment"},
{"data":"DivisionName"},
{"data":"Customer"},
{"data":"WarehouseName"},
{"data":"Coordinator"},
{"data":"ChargebackDate"},
{"data":"ModDate"},
{"data":"ChargebackDeadline"},
{"data":"ChargebackCloseDate"},
{"data":" DaysOpen"},
{"data":"ChargebackAmount"},
{"data":"ChargebackBalance"},
{"data":"FaultName"},
{"data":"ResponsibleName"}
]
});
});
</script>
@using (Html.BeginForm("Index", "Chargeback"))
{
<label id = "Include" > @Html.CheckBox("IncludeClosed", (bool)ViewBag.IncludeClosed, new { onChange = "this.form.submit()" }) Include Closed</label>
<table id="DashboardTable" class="table table-striped" >
<thead>
<tr>
<th>Code</th>
<th>Status</th>
<th>Business</th>
<th>Invoice</th>
<th>Order</th>
<th>Pick Tickets</th>
<th>Customer PO</th>
<th>Assigned</th>
<th>Division</th>
<th>Customer</th>
<th>Warehouse</th>
<th>Coordinator</th>
<th>Open Date</th>
<th>Last Activity</th>
<th>Deadline</th>
<th>Closed Date</th>
<th>Days Open</th>
<th>Amount</th>
<th>Balance</th>
<th>Fault</th>
<th>Responsible</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
var chargebackDeadline = item.ChargebackDeadline == null ? "" : ((DateTime)item.ChargebackDeadline).ToString("MM/dd/yyyy");
var chargebackCloseDateAsString = item.ChargebackCloseDate == null ? "" : ((DateTime)item.ChargebackCloseDate).ToString("MM/dd/yyyy");
<tr>
<td>@Html.ActionLink(item.ChargebackCode, "Details", "Chargeback", new { id = item.Id }, null)</td>
<td>@item.StatusName</td>
<td>@item.BusinessUnitName</td>
<td>@item.InvoiceCode</td>
<td>@item.OrderCode</td>
<td>@item.PickTicketCode</td>
<td>@item.CustomerPo</td>
<td>@item.AssignedDepartment</td>
<td>@item.DivisionName</td>
<td>@item.Customer</td>
<td>@item.WarehouseName</td>
<td>@item.Coordinator</td>
<td>@item.ChargebackDate.ToString("MM/dd/yyyy")</td>
<td>@item.ModDate.ToString("MM/dd/yyyy")</td>
<td>@chargebackDeadline</td>
<td>@chargebackCloseDateAsString</td>
<td>@item.DaysOpen</td>
<td>[email protected]</td>
<td>[email protected]</td>
<td>@item.FaultName</td>
<td>@item.ResponsibleName</td>
</tr>
}
</tbody>
</table>
}
|
|
|
|
|
I don't understand the question. You have code that initializes your datatable when the page loads. Are you asking how to re-load it when you check a checkbox?
If so, var table = $('#grdTable').DataTable();
table.ajax.reload();
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
|
 Should I remove this portion:
$(document).ready(function () {
// var ref = $("#DashboardTable").DataTable({
// "processing": true, // for show progress bar
// "serverSide": true, // for process server side
// "filter": true, // this is for disable filter (search box)
// "orderMulti": false, // for disable multiple column at once
// "pageLength": 5,
// "ajax": {
// "url": "/Chargeback/Index",
// "type": "GET",
// "datatype": "json"
// },
// "columnDefs":
// [{
// "targets": [0],
// "visible": false,
// "searchable": false
// },
// {
// "targets": [7],
// "searchable": false,
// "orderable": false
// },
// {
// "targets": [8],
// "searchable": false,
// "orderable": false
// },
// {
// "targets": [9],
// "searchable": false,
// "orderable": false
// }],
// "columns": [
// { "data": "ChargebackCode" },
// { "data": "StatusName" },
// { "data": "BusinessUnitName" },
// { "data": "InvoiceCode" },
// { "data": "OrderCode" },
// { "data": "PickTicketCode" },
// { "data": "CustomerPo" },
// { "data": "AssignedDepartment" },
// { "data": "DivisionName" },
// { "data": "Customer" },
// { "data": "WarehouseName" },
// { "data": "Coordinator" },
// { "data": "ChargebackDate" },
// { "data": "ModDate" },
// { "data": "ChargebackDeadline" },
// { "data": "ChargebackCloseDate" },
// { "data": " DaysOpen" },
// { "data": "ChargebackAmount" },
// { "data": "ChargebackBalance" },
// { "data": "FaultName" },
// { "data": "ResponsibleName" }
// ]
// });
//});
and just add this portion:
var table = $('#grdTable').DataTable();
table.ajax.reload();
|
|
|
|
|
No, that first part initializes your table. The second part just tells it to refresh.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
 So basically this, This is in my .js file I would link this to my view in mvc:
var table = $('#DashboardTable').DataTable;
table.ajax.reload();
$(document).ready(function () {
$("#DashboardTable").DataTable({
"processing": true, // for show progress bar
"serverSide": true, // for process server side
"filter": true, // this is for disable filter (search box)
"orderMulti": false, // for disable multiple column at once
"pageLength": 5,
"ajax": {
"url": "/Chargeback/Index",
"type": "GET",
"datatype": "json"
},
"columnDefs":
[{
"targets": [0],
"visible": false,
"searchable": false
},
{
"targets": [7],
"searchable": false,
"orderable": false
},
{
"targets": [8],
"searchable": false,
"orderable": false
},
{
"targets": [9],
"searchable": false,
"orderable": false
}],
"columns": [
{ "data": "ChargebackCode" },
{ "data": "StatusName" },
{ "data": "BusinessUnitName" },
{ "data": "InvoiceCode" },
{ "data": "OrderCode" },
{ "data": "PickTicketCode" },
{ "data": "CustomerPo" },
{ "data": "AssignedDepartment" },
{ "data": "DivisionName" },
{ "data": "Customer" },
{ "data": "WarehouseName" },
{ "data": "Coordinator" },
{ "data": "ChargebackDate" },
{ "data": "ModDate" },
{ "data": "ChargebackDeadline" },
{ "data": "ChargebackCloseDate" },
{ "data": " DaysOpen" },
{ "data": "ChargebackAmount" },
{ "data": "ChargebackBalance" },
{ "data": "FaultName" },
{ "data": "ResponsibleName" }
]
});
});
modified yesterday.
|
|
|
|
|
No, you want the reload code in a function, then when you click the checkbox you call that function.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Can you provide a example of what you mean?
|
|
|
|
|
KGr28 wrote: Can you provide a example of what you mean? It is very, very, basic JavaScript. You can copy and paste from what I give you as an example but you need to understand how it works.
fucntion ReloadTable(){
}
Then, if you don't know how, google how to run javascript when checking a box.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Sorry I am new to javascript hence all of the questions, just trying to get a clear understanding of what exactly you are trying to say.
|
|
|
|
|
I have an ASP.net MVC Web API developed in VS2017 using C# 4.5.2.
I'm trying to deploy it to IIS on a Windows Server 2019 box on the same network by following this article.
- Right Click the project and choose Publish.
- Click New Profile
- Select "IIS,FTP,etc" and click "Create Profile"
- In the Connection dialog, I fill in the server's IP (192.162.50.153), the Site Name, my User Name and Password, and click the "Validate Connection" button.
I get
Could not connect to the remote computer ("192.168.50.153") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC. The remote server returned an error: (403) Forbidden.
I went to the link in the message.
A. I can Ping the machine
B. The Web Deploy Service is running
C. The port is opened.
What am I doign wrong?? What's the right way to deploy/install my Web API to my server on the same network?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Given we have no access to your network or the machines running on it it is impossible to say why your machine can't connect to the target. If you can't get an IIS deploy working just do a "File" deploy to a folder on your local machine and upload the contents of that folder to the web space for your site on the IIS server.
|
|
|
|
|
I've done a file deploy. I can's access the web API, even locally, which is what led me to the Publish option.
One thing I just found is the logs shows HttpStatus 403 and HttpSubStatus 503. if you look at that here, you'll see that it says "403.503 - Forbidden: the IP address is included in the Deny list of IP Restriction"
I've checked and rechecked, and there are NO restrictions set up.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Thanks. Already saw that.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I am trying to create a checkbox which AutoPostBack when a checkbox is clicked :
ex.@Html.CheckBox("IncludeClosed", true, new { onChange = "this.form.submit()"})
but i get error:Uncaught TypeError: Cannot read property 'submit' of null
and If I inspect my code in Developer tools in the browser this is returned:
<input checked="checked" id="IncludeClosed" name="IncludeClosed" onChange="this.form.submit()" type="checkbox" value="true" />input name="IncludeClosed" type="hidden" value="false"
modified 25-Jun-19 14:18pm.
|
|
|
|
|
Is your checkbox definitely inside a <form> tag? If not, then this.form will return null .
The extra hidden input is perfectly normal. The ASP.NET forums have an explanation:
When you submit a form with a checkbox, the value is only posted if the checkbox is checked. So, if you leave the checkbox unchecked then nothing will be sent to the server when in many situations you would want false to be sent instead. As the hidden input has the same name as the checkbox, then if the checkbox is unchecked you'll still get a 'false' sent to the server.
When the checkbox is checked, the ModelBinder will automatically take care of extracting the 'true' from the 'true,false'
If you absolutely want to avoid the extra hidden input you can create your own helper method, as discussed in this StackOverflow thread[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So I discovered when I updated my CheckBox helper method to :
@Html.CheckBox("IncludeClosed", false, new { onChange = "this.IncludeClosed.submit()"})
This is my form:
@using (Html.BeginForm("Index","Chargeback",FormMethod.Get,new { id = "IncludeClosed"}))
but I get a new error:
Cannot read property 'submit' of undefined
modified 25-Jun-19 15:39pm.
|
|
|
|
|
Javascript doesn't create global variables for elements in your page. If you want to refer to an element by ID, you have to use the document.getElementById method[^].
@Html.CheckBox("IncludeClosed", false, new { onChange = "document.getElementById('IncludeClosed').submit()"})
But if your checkbox is outside of your form, it's not going to be sent back to the server. Only the input elements within the form will be submitted with the form.
You might be able to use the form attribute[^] to work around that. But it's not supported in any version of Internet Explorer or Microsoft Edge. If you need to support either of those browsers, you'll have to move the checkbox inside the form - at which point, your original code will start working.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This approach gives me an error b/c document doesn't exist in the current context also if a submit it as a string then it doesn't recognize the function.
@Html.CheckBox("IncludeClosed", false, new { onChange = "document.getElementById('IncludeClosed').submit()"})
|
|
|
|
|
I figured it out I added the checkbox inside of the form like you suggested and it works:
@using (Html.BeginForm("Index", "Chargeback"))
{
@Html.CheckBox("IncludeClosed", false, new { onChange = "this.form.submit()" })
I am getting the result of true,false but I believe you mentioned how to solve this issue.
Thank you again.
|
|
|
|
|
I'm getting the following warnings when I compile my MVC5 app:
warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Owin.Security.Cookies". Check to make sure the assembly exists on disk.
warning MSB3243: No way to resolve conflicgt between "Microsoft.Owin.Security.Cookies, Version=4.0.1.0, Culture=nuetral, PublicKeyToken=31bf3856ad364e35" and "Microsoft.Owin.Security.Cookies". Choosing "Microsoft.Owin.Security.Cookies, Version=4.0.1.0, Culture=nuetral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
The assembly in question is a nuget package, and it exists in my local nuget repository, and the reference reflects the proper (nuget) path. My web config contains the following:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
</dependentAssembly>
I'm at a loss. The app compiles with these two warnings, but seems to run fine (since it's evidently selecting the referenced assembly "arbitrarily".
I hate warnings. How do I resolve them?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 26-Jun-19 6:53am.
|
|
|
|
|