-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserprofile.aspx.cs
More file actions
84 lines (80 loc) · 2.77 KB
/
userprofile.aspx.cs
File metadata and controls
84 lines (80 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Security.Cryptography;
public partial class userprofile : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["reg"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["Email"].ToString() == "" || Session["Email"] == null)
{
Response.Write("<script>alert('Session Expired Login Again');</script>");
Response.Redirect("login.aspx");
}
else
{
getuserdata();
img.ImageUrl = "photoHandler.ashx?Email=" + Base64Encode(Session["Email"].ToString());
}
}
catch (Exception)
{
Response.Write("<script>alert('Session Expired Login Again');</script>");
Response.Redirect("login.aspx");
}
}
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
public static string Base64Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
//edit btn clicked
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("updateprofile.aspx");
}
void getuserdata()
{
try
{
SqlCommand cmd = new SqlCommand("select * from signup where Email='"+Session["Email"]+"';", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count >= 1)
{
Label16.Text = dt.Rows[0]["Name"].ToString();
Label15.Text = dt.Rows[0]["Category"].ToString();
Label1.Text = dt.Rows[0]["Name"].ToString();
Label2.Text = dt.Rows[0]["Email"].ToString();
Label3.Text = dt.Rows[0]["DOB"].ToString();
Label4.Text = dt.Rows[0]["Mobile"].ToString();
Label5.Text = dt.Rows[0]["Country"].ToString();
Label6.Text = dt.Rows[0]["State"].ToString();
Label7.Text = dt.Rows[0]["Address"].ToString();
}
}
catch(Exception ex)
{
Response.Write("<script>alert("+ex.Message+")</script>");
}
}
}