|
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.
|
|
|
|
|
Member 12847869 wrote: How to add languages on a website? What does this mean? Do you want multiple languages to show? Do you want the user to change the language? Are you translating everything?
Member 12847869 wrote: How to security a website professionally? Is there a database back-end? What kind of server? IIS? Apache? Do you need to secure certain pages or the whole site? Is anonymous allowed?
Hopefully you can see that your question needs a ton more detail for anyone to help.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have created an API with Client Identifier, Client Secrets, Auth URL and Access Token URL in Vimeo. Still searching for solution to fetch private videos from Vimeo using REST/ JSON/ JQuery.
Any help appreciated to provide some sample code to fetch private videos from Vimeo using REST/ JSON/ JQuery.
|
|
|
|
|
I would suggest starting at Vimeo Developer API[^].
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
How do I get apis for Facebook, Google talk, skype, whatsapp for my project using javascript and html? How can i import my facebook, google talk, skype and whatsapp friends and chat through my website?
|
|
|
|
|
Go to Facebook, Google etc developer websites and study the documentation.
|
|
|
|
|
Thanks Mr. Richard MacCutchan. I followed that process I am able to login to facebook and google but I got nothing to import friends into my website. For facebook i used a code which provide me only list of friends to tag them not for chat. In google i used gapi.client.people.list but it returns item[] zero means no friends. For Skype they have mentioned that APIs are not public and same for whatsapp, So I can't login to skype and whatsapp. If you have solution please guide.
|
|
|
|
|
Member 12336044 wrote: For Skype they have mentioned that APIs are not public and same for whatsapp, So I can't login to skype and whatsapp. If you have solution please guide. And exactly how do you think we can provide a solution to that?
|
|
|
|
|
Sir I m now in programming field so i thought there can be any solution that experts can give that is not directly mentioned on internet. So that why I asked.
|
|
|
|
|