|
How are we supposed to know what is happening without being able to see anything?
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Magic!
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi All,
I have a script which downloads the file from the server. Its was working fine, but its throwing error now.
I am getting error while creating the object using WScript.
please let me know how to fix this issue.
<html>
<head>
<script Language ="Javascript">
var userId = "fm012097";
window.alert(userId)
var password = "Bllchr1$";
window.alert(password)
var localDirectory = "c:\\temp";
window.alert(localDirectory)
var oHDL = WScript.CreateObject( "DSTHTTPDL.DownloadManager" );
oHDL.Host = "xyz.com";
oHDL.Target = "/sample";
alert(oHDL.Target)
oHDL.Client = "415171403";
oHDL.UseProxy = false;
oHDL.UseHttps = true;
oHDL.Asynchronous = false;
oHDL.UserID = userId;
oHDL.Password = password;
oHDL.LocalDirectory = localDirectory;
window.alert(oHDL)
var fileListing = oHDL.GetFileListAsXML();
window.alert(fileListing)
var xmldoc = WScript.CreateObject( "Msxml2.DOMDocument.4.0" );
xmldoc.async = false;
xmldoc.preserveWhiteSpace = true;
xmldoc.loadXML( fileListing );
var dListing = "";
var docelement = xmldoc.documentElement;
window.alert(docelement)
var iCount = 0;
if ( docelement.hasChildNodes() )
{
var nodeList = docelement.childNodes;
var node = nodeList.nextNode();
while ( node != null )
{
var file = node.getAttribute( "name" );
var display = node.getAttribute( "short-name" );
window.alert(file+''+display)
dListing += file;
dListing += ";";
iCount++;
node = nodeList.nextNode();
}
}
oHDL.DownloadFiles( dListing )
oHDL = null;
</script>
</head>
</html>
|
|
|
|
|
That is simple, how are you telling JavaScript, where to look for WScript definition? It requires JScript by Microsoft and will only run on Windows, where you can execute wscript.exe executable.
For example, look here javascript - ReferenceError: WScript is not defined - Stack Overflow[^], or here, VBScript and CreateObject issue - Stack Overflow[^]. Then again, it would heavily require clients to have dependencies installed.
If the purpose is just to download, why can't you use native JavaScript, or a minimal C++ program?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
The error would tell you what the problem is. Is there a reason you did not include the error?
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi,
I was wondering if someone could please help me with the following code as it doesn't seem to be working and I cant work out why. Basically, I am attempting to create a document referrer so if a user on a website comes from X site (that site only) then they are redirected to A but if they come from Y they are redirected to B, while if they come from an internal source then they can continue.
The code is:
<pre lang="Javascript">
var regExp = /https:\/\/(anon.to)\/(xxxxxx)/g;
var dr = document.referrer;
if (dr == '') {
self.location='WebsiteExample1';
} else if (dr.match(regExp)) {
self.location ='Otherplaceonwebsite';
}
The code works if I just use var regExp = /https:\/\/(anon.to)/g; but that allows anyone from anon.to to access the link rather than just the users with the https://anon.to/xxxxxx link.
Hopefully this makes sense and someone can help.
Thanks,
|
|
|
|
|
Quote: Create a secure anonymous short link from your url which also hides http referer!
The service you're using deliberately hides the referrer information. Therefore, you can't use the referrer to detect whether the user came from your anon.to link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
function getLocation() {
navigator.geolocation.getCurrentPosition(function (pos) {
var lat = pos.coords.latitude;
var lng = pos.coords.longitude;
if (lat == null) {
navigator.notification.alert("GPS not activated!", null, "GPS", "Ok");
}
else {
navigator.notification.alert("Latitude: " + lat + " , Longitude: " + lng, null, "GPS", "Ok");
}
});
}
|
|
|
|
|
I have deleted your other versions of this question, please post once only. Also, you need to explain what your problem is.
|
|
|
|
|
Even a device has active GPS it is possible that your JS code will not benefit from this, that because browsers will not let you know the location without permission from the user... The problem is that browsers remember the hoise for every site, so once the user voted 'no' you have no way to force him choose again...
But, there is one way may help you... Connect 'getCurrentPosition' - directly - to a button click, in this case it considered as an action by the user and will be permitted... Of course you have to exactly describe to the user what will happening what clicking the button...
A good reading: Geolocation - Dive Into HTML5[^]
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Quote: How to find user device is gps is on or off Android or ios using js? You are aware of the fact that GPS is a system feature in Android and not a browser feature, right? You can get the location, but to detect or determine you will have rely on the user, as browser won't be able to trigger changes itself.
Offline devices will return the most recent locations, not accurate or live locations. If you mean to say that location APIs are available then read here,
Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. No guarantee is given that the API returns the device's actual location. So, you can simply request the users to enable GPS for better results.
Also, you should try to check for navigator.geolocation to be set to null or not, otherwise results may be generated.
if (navigator.geolocation) {
} else {
}
For more,
javascript - how capturing geolocation with device offline - cordova - Stack Overflow[^]
Accessing GPS data with JavaScript in real time - Geographic Information Systems Stack Exchange[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I'm trying to understand two way binding in AngularJS but I'm unable to understand the behavior of functions and variables.
Consider the following example:
So, I have a controller like this:
var app=angular.module("cal", []);
app.controller("calc",function ($scope) {
$scope.result=Number($scope.a || 0)+ Number($scope.b || 0);
});
and HTML like this:
<div ng-app="cal">
<div ng-controller="calc">
<input type="text" ng-model="a"/>
<input type="text" ng-model="b"/>
<span>{{result}}</span>
</div>
</div>
This code doesn't update the variable "result".
However, if I use something like this:
var app=angular.module("cal", []);
app.controller("calc",function ($scope) {
$scope.add = function(){
return (Number($scope.a || 0)+ Number($scope.b || 0));
}
});
and
<div ng-app="cal">
<div ng-controller="calc">
<input type="text" ng-model="a"/>
<input type="text" ng-model="b"/>
<span>{{add()}}</span>
</div>
</div>
the value in gets updated automatically with variation in variables "a" or "b".
How does this work? What's the difference in returning from the function and using the variable directly in the DOM?
|
|
|
|
|
There's a few ways to handle this, but since this is a basic operation you can do it directly in the angular tag. I would just advise declaring your scope properties in the controller for stability.
app.controller('calc',['$scope',function($scope){
$scope.a = 0;
$scope.b = 0;
});
<div ng-app="cal">
<div ng-controller="calc">
<input type="text" ng-model="a"/>
<input type="text" ng-model="b"/>
<span>{{ a + b }}</span>
</div>
</div>
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I get this but this isn't what I asked. I want to know why using the variable "result" doesn't work. Doesn't Angular update it along with variables "a" and "b"?
|
|
|
|
|
Well, because you're assigning it as part of controller construction. If you want it to update then you'll need to watch the source variables:
app.controller('calc',['$scope',function($scope){
$scope.a = 0;
$scope.b = 0;
$scope.result = 0;
$scope.calculate = function(){
$scope.result = $scope.a + $scope.b;
}
$scope.$watch('a',$scope.calculate);
$scope.$watch('b',$scope.calculate);
});
Personally I think in this sort of operation that an aggregate variable is overkill, and it would be better to directly inject $scope.a and $scope.b into a request, if that's what you're goal is.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Yes, but why don't we have to watch in case of using "add()"? Does Angular watch for functions automatically and for using variables in view do we have to watch them manually?
|
|
|
|
|
Because you're binding to a function in the markup. That means that every time a digest cycle is run, that function is executed. That's definitely not the ideal way to bind, and potentially extremely buggy.
Have a look at the Scope Lifecycle section of:
AngularJS Developer's Guide[^]
The important thing to remember is that the page rendering (anything on the template) is processed when the $digest is run, so loading functions directly into it can become a very expensive process.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
OK. What's the ideal way to bind?
|
|
|
|
|
If you absolutely need an aggregate from other scope properties bound to a scope property, the ideal way to bind is to $scope.$watch the base properties.
If you need a transform from a scope property, but do not need the result bound to a property (a totals row, for instance) the ideal way is either native functions or filters.
Methods should really be saved for event handling and processing.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hi,
I am trying to use AngularJS in my application, I am new to AngularJS, I am trying to use it with ASP.Net MVC 5, can anybody please help me? I am trying to execute the npm install from my Application route folder where project.json exists, but npm install is saying project.json file doesn't exist even it exists.
But I have just copied the project.json from some other Project, I don't know if its wrong or I shouldn't do it. But I don't know what to write in my project.json file. I don't have any other files copied too.
Should I have some other files? Any help is going to be very helpful, thanks in advance
My project.json file as below
{
"webroot": "wwwroot",
"version": "1.0.1-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Glimpse": "2.0.0-beta1",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx46": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Post your file structure and the actual error message here otherwise difficult to answer.
|
|
|
|
|
Hello,
I have created a job application form.
I need to send this form converted as .pdf file via mail.
Code behind
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.html;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Text;
using System.Net.Mime;
using System.IO;
namespace myproject
{
public partial class ApplicationForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Session.Remove("clicks");
}
}
protected MemoryStream getMemoryStream()
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
this.Page.RenderControl(w);
string s = sw.GetStringBuilder().ToString();
SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
SelectPdf.PdfDocument doc = converter.ConvertHtmlString(s);
MemoryStream Stream = new MemoryStream();
doc.Save(Stream);
doc.Close();
return Stream;
}
protected String getHtml()
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
this.Page.RenderControl(w);
string s = sw.GetStringBuilder().ToString();
return s;
}
protected void add_Click(object sender, EventArgs e)
{
int rowCount = 7;
rowCount = Convert.ToInt32(Session["clicks"]);
rowCount++;
Session["clicks"] = rowCount;
for (int i = 0; i < rowCount; i++)
{
TextBox TxtBoxE = new TextBox();
TextBox TxtBoxP = new TextBox();
TextBox TxtBoxD = new TextBox();
TextBox TxtBoxS = new TextBox();
TextBox TxtBoxR = new TextBox();
Label lblE = new Label();
Label lblP = new Label();
Label lblD = new Label();
Label lblS = new Label();
Label lblR = new Label();
TxtBoxE.ID = "TextBoxE" + i.ToString();
TxtBoxP.ID = "TextBoxP" + i.ToString();
TxtBoxD.ID = "TextBoxD" + i.ToString();
TxtBoxS.ID = "TextBoxS" + i.ToString();
TxtBoxR.ID = "TextBoxR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.Text = "Employer " + (i + 1).ToString() + " : ";
lblP.Text = "Position " + (i + 1).ToString() + " : ";
lblD.Text = "From-Until : ";
lblS.Text = "Salary " + (i + 1).ToString() + " : ";
lblR.Text = "Reason for Leaving " + (i + 1).ToString() + " : ";
Panel1.Controls.Add(lblE);
Panel1.Controls.Add(TxtBoxE);
Panel1.Controls.Add(lblP);
Panel1.Controls.Add(TxtBoxP);
Panel1.Controls.Add(lblD);
Panel1.Controls.Add(TxtBoxD);
Panel1.Controls.Add(lblS);
Panel1.Controls.Add(TxtBoxS);
Panel1.Controls.Add(lblR);
Panel1.Controls.Add(TxtBoxR);
}
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
string fname = "applicationForm" + DateTime.Now.ToString("yyMMddHHmmss") + ".pdf";
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(txtmymail.Text);
mailMsg.To.Add("my-email@gmail.com");
mailMsg.IsBodyHtml = true;
mailMsg.Subject = "Contact Details";
MemoryStream file = getMemoryStream();
FileStream filePDF = new FileStream(fname, FileMode.Create, FileAccess.Write);
file.WriteTo(filePDF);
file.Close();
filePDF.Close();
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf);
System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(fname, ct);
attach.ContentDisposition.FileName = fname;
ContentDisposition disposition = attach.ContentDisposition;
disposition.CreationDate = DateTime.Now;
mailMsg.Attachments.Add(attach);
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
mailMsg.Priority = MailPriority.Normal;
smtp.Credentials = new System.Net.NetworkCredential("my-email@gmail.com", "my-email-password");
smtp.Timeout = 250000;
smtp.EnableSsl = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
smtp.Send(mailMsg);
Response.Write("<Script>alert('Thanks for contact us,our team will be contact you as soon as possible')</Script>");
txtfname.Text = "";
txtlname.Text = "";
txtfaname.Text = "";
txtmoname.Text = "";
txtmymail.Text = "";
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationForm.aspx.cs" EnableEventValidation="false" Inherits="icts.ApplicationForm" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server" >
<meta charset="UTF-8"/>
<title>Job Application</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"/>
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/style.css" rel="stylesheet"/>
</head>
<body>
<form method="get" runat="server" id="form1">
<div class="container">
<h5>GENERAL INFORMATION</h5>
<div class="row">
<div class="col-md-6" id="col-md-6">
<div class="col-sm-9">
<div class="col-xs-8 col-sm-6">
<span>Surname</span>
</div>
<div class="col-xs-8 col-sm-6">
<asp:TextBox ID="txtlname" runat="server"></asp:TextBox>
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-sm-9">
<div class="col-xs-8 col-sm-6">
<span>Name</span>
</div>
<div class="col-xs-8 col-sm-6">
<asp:TextBox ID="txtfname" runat="server"></asp:TextBox>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6" id="col-md-6">
<div class="col-sm-9">
<div class="col-xs-8 col-sm-6">
<span>Date of Birth</span>
</div>
<div class="col-xs-8 col-sm-6">
<asp:Textbox type="date" runat="server" ID="bday"></asp:Textbox>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<asp:Panel ID= "Panel1" runat = "server"></asp:Panel>
<asp:Button ID="Button2" runat="server" Text="Add field" OnClick="add_Click" />
</div>
</div>
<div class="row">
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="btnsubmit_Click" />
</div>
With this code i am able to send a .pdf attachment via mail, but some of the fields are empty.
My form has text boxes, date input and radio buttons.
What would you suggest?
Thank you,
|
|
|
|
|
You might have better luck in the ASP.NET forum.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
How to add languages on a website?
How to security a website professionally?
|
|
|
|
|
Try Google for research questions.
|
|
|
|
|