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
P.Suresh Kumar
NA
55
6.6k
Passing values from database to next page
Apr 7 2019 11:55 PM
new.aspx :
<%@ Page Language=
"C#"
AutoEventWireup=
"true"
CodeFile=
"new.aspx.cs"
Inherits=
"View_new"
%>
<meta charset=
"UTF-8"
/>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
/>
<link rel=
"stylesheet"
media=
"screen"
href=
'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css'
/>
<!-- jQuery library -->
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
></script>
<!-- Latest compiled JavaScript -->
<script src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
></script>
<script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"
></script>
<link rel=
"stylesheet"
href=
"new.css"
/>
<style type=
"text/css"
>
body {
background: -webkit-linear-gradient(left, #1143a6, #00c6ff);
}
</style>
<script type=
"text/javascript"
>
var
LoginApp = angular.module(
'LoginApp'
, []);
LoginApp.controller(
'LoginController'
, [
'$scope'
,
'$http'
,
'$window'
,
function
($scope, $http, $window) {
$scope.submit =
function
() {
var
UserData = { username: $scope.Username, password: $scope.Password}
$http.post(
'new.aspx/btnLogin_Click'
, UserData)
.success(
function
(data, status, headers, config) {
if
(data.d !=
""
) {
$scope.message = data.d;
}
else
{
$window.location.href =
'success.aspx'
;
}
}).error(
function
(data, status, headers, config) {
$scope.message = data.d;
});
}
}]);
</script>
<form id=
"formID"
runat=
"server"
>
<div ng-controller=
"LoginController"
>
<asp:hiddenfield id=
"hdnScreenHeight"
runat=
"server"
/>
<asp:hiddenfield id=
"hdnScreenWidth"
runat=
"server"
/>
<section
class
=
"container "
>
<div
class
=
"main_cont register"
>
<div
class
=
"login-panel"
>
<h3
class
=
"login-heading"
>Zetekcastings</h3>
<div
class
=
"row"
>
<div
class
=
"col-md-12 col-sm-12"
>
<div
class
=
"form-group"
>
<asp:textbox type=
"text"
class
=
"form-control"
id=
"txtUserName"
runat=
"server"
ng-model=
"Username"
name=
"Name"
placeholder=
"Username"
value=
""
autocomplete=
"off"
required></asp:textbox>
</div>
<div
class
=
"form-group"
>
<asp:textbox type=
"password"
class
=
"form-control"
id=
"txtPassword"
runat=
"server"
ng-model=
"Password"
name=
"Password"
placeholder=
"Password"
value=
""
autocomplete=
"off"
required></asp:textbox>
</div>
<div
class
=
"float-right"
>
<asp:button type=
"button"
id=
"btnLogin"
runat=
"server"
onclick=
"btnLogin_Click"
text=
"Login"
class
=
"btn btn-primary"
value=
"Login"
></asp:button>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</form>
new.aspx.cs :
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Data.SqlClient;
using
System.Net;
using
System.Globalization;
using
System.IO;
public
partial
class
View_new : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
//this.txtUserName.Text = Request.QueryString["username"];
}
protected
void
btnLogin_Click(
object
sender, EventArgs e)
{
//string filepath = Server.MapPath("~/PMCustom/images/") + "top-button.png";
//FileInfo file = new FileInfo(filepath);
//Response.ClearContent();
//Response.AddHeader("Content-Disposition", "attachment;filename=" + file.Name);
//Response.TransmitFile(file.FullName);
//Response.End();
SqlCommand lsCmd =
new
SqlCommand(
"SP_VALIDATE_LOGIH"
);
lsCmd.Parameters.AddWithValue(
"@USERNAME"
, txtUserName.Text);
lsCmd.Parameters.AddWithValue(
"@PASSWORD"
, txtPassword.Text);
DataTable dt = ConnCls.ret_dt_Cmd(lsCmd);
string
strUserid = dt.Rows[0][
"USERID"
].ToString();;
//string strDataMode = dt.Rows[0]["DATAMODE"].ToString();
string
strloggedInTime = System.DateTime.Now.ToString();
string
strhostName = Dns.GetHostName();
string
strIpAddress = Dns.GetHostByName(strhostName).AddressList[0].ToString();
if
(strUserid !=
"0"
)
{
HttpCookie userid =
new
HttpCookie(
"userid"
);
userid.Value = strUserid;
Response.Cookies.Add(userid);
string
doll = Request.Cookies[
"userid"
].Value;
Response.Write(doll);
HttpCookie username =
new
HttpCookie(
"username"
);
username.Value = txtUserName.Text;
Response.Cookies.Add(username);
string
roll = Request.Cookies[
"username"
].Value;
Response.Write(roll);
//HttpCookie ipaddress = new HttpCookie("ipaddress");
//ipaddress.Value = Dns.GetHostByName(strhostName).AddressList[0].ToString();
//Response.Cookies.Add(ipaddress);
//int loginIdVal = insertLog(strUserid, strUserName);
//HttpCookie loginId = new HttpCookie("logInId");
//loginId.Value = loginIdVal.ToString();
//Response.Cookies.Add(loginId);
//HttpCookie dataMode = new HttpCookie("dataMode");
//dataMode.Value = strDataMode.ToString();
//Response.Cookies.Add(dataMode);
if
(strUserid !=
"0"
)
{
Response.Redirect(
"~/home/accountshome.html"
);
}
}
}
public
int
insertLog(
string
pUserid,
string
pUsername)
{
System.Web.HttpBrowserCapabilities objHBC = Context.Request.Browser;
string
userLanguage = CultureInfo.CurrentCulture.Name;
SqlCommand cmd =
new
SqlCommand(
"PM_INSERT_LOG"
);
cmd.Parameters.Add(
"@USERID"
, pUserid);
cmd.Parameters.Add(
"@USERNAME"
, pUsername);
cmd.Parameters.Add(
"@BROWSERNAME"
, objHBC.Browser);
cmd.Parameters.Add(
"@VERSION"
, objHBC.Version);
cmd.Parameters.Add(
"@SPIXELHEIGHT"
, hdnScreenHeight.Value);
cmd.Parameters.Add(
"@SPIXELWIDTH"
, hdnScreenWidth.Value);
cmd.Parameters.Add(
"@ISMOBILE"
, objHBC.IsMobileDevice.ToString());
cmd.Parameters.Add(
"@ISJAVASCRIPT"
, objHBC.JavaScript.ToString());
cmd.Parameters.Add(
"@BROWSERTYPE"
, objHBC.Type);
cmd.Parameters.Add(
"@MOBILEMODEL"
, objHBC.MobileDeviceModel.ToString());
cmd.Parameters.Add(
"@CLIENTDETAIL"
, Context.Request.UserAgent.ToString());
cmd.Parameters.Add(
"@ISTABLES"
, objHBC.Tables.ToString());
cmd.Parameters.Add(
"@ISCOOKIES"
, objHBC.Cookies.ToString());
cmd.Parameters.Add(
"@ISACTIVEX"
, objHBC.ActiveXControls.ToString());
cmd.Parameters.Add(
"@PLATFORM"
, objHBC.Platform);
cmd.Parameters.Add(
"@USERLANGUAGE"
, userLanguage);
DataTable dt = ConnCls.ret_dt_Cmd(cmd);
string
returnVal = dt.Rows[0][
"LOGINID"
].ToString();
return
Convert.ToInt32(returnVal);
}
}
accountsHomehtml :
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<title></title>
<!--<script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"
></script>
<script type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular-cookies.js"
></script>-->
<!--<link rel=
"stylesheet"
href=
"new.css"
/>-->
<script type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"
></script>
<script type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-cookies.js"
></script>
<!--<script type=
"text/javascript"
>
var
app = angular.module(
"LoginApp"
, [
'ngCookies'
])
.controller(
"LoginController"
,
function
($scope, $cookies) {
debugger
;
$scope.getUsername =
function
() {
debugger
;
//$window.alert($cookies.get("username"));
return
$cookies.get(
"username"
);
}
$scope.getUserid =
function
() {
debugger
;
return
$cookies.get(
"userid"
);
}
});
</script>-->
</head>
<body ng-app=
"LoginApp"
ng-controller=
"LoginController"
>
<div>
<h3>Login successful!</h3>
</div>
<div>
Username : <span id=
"lblUserName"
class
=
"hidden-xs"
>{{getUsername()}}</span><br />
User Id : <span id=
"lblUserId"
class
=
"hidden-xs"
>{{getUserid()}}</span>
</div>
</body>
</html>
newAjs.js :
var
app = angular.module(
"LoginApp"
, [
'ngCookies'
])
.controller(
"LoginController"
,
function
($scope, $cookies) {
$scope.getUsername =
function
() {
return
$cookies.get(
"username"
);
}
$scope.getUserid =
function
() {
return
$cookies.get(
"userid"
);
}
});
I can display the values by checking it in the database in the same page, but I cannot pass it to the next page. I don't know what mistake I have done.
Reply
Answers (
3
)
why's the error not found namespace or class ?
Difference between UpdateModel and TryUpdateModel