TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rupesh N
NA
380
46.6k
Error: 2nd time enter login page will Success.
Aug 1 2018 10:43 PM
Hi. My name is Rupesh.
Actully, i am creating login page with help of angularjs and webmethod.
problem is, first enter login details not connect .
but, second time same details enter will connected.
so, please any one tell me where is the problem.
it's very urgent guys. my job issue. please tell me anyone.
Thank you.
Angularjs:
<script type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"
></script>
var
app = angular.module(
'myApp'
, []);
app.controller(
'myController'
,
function
($http, $scope, $window) {
$scope.savedata =
function
() {
debugger
var
post = $http({
method:
"post"
,
url:
"login.aspx/insertpassword"
,
dataType:
'json'
,
data: { Username: $scope.username, Password: $scope.password },
headers: {
"ContentType"
:
"application/json"
}
});
post.success(
function
(data, status) {
$window.alert(data.d);
if
(data.d ==
'ok'
)
{
window.location =
'http://localhost:12035/user/dashboard.aspx'
;
}
else
{
$window.alert(data.d);
}
});
post.error(
function
(data, status) {
$window.alert(data.d);
});
}
});
Html code:
<
body
ng-app
=
"myApp"
ng-controller
=
"myController"
>
<
div
class
=
"form-group"
>
<
label
class
=
"form-label"
>
Email address
</
label
>
<
input
type
=
"email"
class
=
"form-control"
id
=
"exampleInputEmail1"
ng-model
=
"username"
aria-describedby
=
"emailHelp"
placeholder
=
"Enter email"
/>
</
div
>
<
div
class
=
"form-group"
>
<
label
class
=
"form-label"
>
Password
<
a
href
=
"./forgot-password.html"
class
=
"float-right small"
>
I forgot password
</
a
>
</
label
>
<
input
type
=
"password"
class
=
"form-control"
id
=
"exampleInputPassword1"
ng-model
=
"password"
placeholder
=
"Password"
/>
</
div
>
<
div
class
=
"form-footer"
>
<
button
type
=
"submit"
class
=
"btn btn-primary btn-block"
ng-click
=
"savedata()"
>
Sign in
</
button
>
</
div
>
</
body
>
Webmethod:
public
static
string
insertpassword(
string
Username,
string
Password)
{
using
(SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"dbconnect"
].ConnectionString))
{
SqlCommand cmd =
new
SqlCommand(
"Logincheck"
, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@UserName"
, Username);
cmd.Parameters.AddWithValue(
"@Password"
, Password);
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
DataSet ds =
new
DataSet();
da.Fill(ds);
if
(Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString())>0)
{
HttpContext.Current.Session[
"UserID"
] = Username;
return
"ok"
;
}
else
{
// error.Visible = true;
return
"UserName or Password Invalid"
;
}
}
}
Reply
Answers (
3
)
What module need to include in user management web applicati
EEPLUS how to get range and loop