Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,030

HOME > .NET Framework > Forum > พี่ครับ ช่วยอธิบายการทำให้user แก้ไข ข้อมูลส่วนตัว หลัง จาก login แล้วหน่อยครับ



 

พี่ครับ ช่วยอธิบายการทำให้user แก้ไข ข้อมูลส่วนตัว หลัง จาก login แล้วหน่อยครับ

 



Topic : 043722



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์




พี่ครับ ช่วยอธิบายการทำให้user แก้ไข ข้อมูลส่วนตัว หลัง จาก login แล้วหน่อยครับ

คือผม สามารถทำ Login ได้แล้ว
เมื่อ login จะมีการเก็บค่า Session("userid") = txtUsername.Text ไว้

ซึ่งถ้า จะเข้าไปแก้ไข ข้อมูลส่วนตัว Session("userid") <> "" ครับ จึงสามารถเข้าไปได้
แล้วทีนี้ จะให้

พอเข้ามาแล้ว ให้ โชว์ข้อมูลของ คนนี้ใน TextBox ยังไงครับ ทั้ง Username email ชื่อ ประมาณนี้ครับ

แบบว่ามันต้องไป เลือกมาจาก ฐานข้อมูล แต่จะเขียนโค็ดยังไงให้ เช็ค ว่า เป็นคนนี้ อยู่ตรงฐานข้อมูลตำแหน่งนี้แล้วเอามาโชว์ครับ



ขอบคุณมากครับผม

ผมใช่ ASP.net นะครับ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-06-07 15:21:56 By : ang89gunner View : 2784 Reply : 23
 

 

No. 1



โพสกระทู้ ( 294 )
บทความ ( 0 )



สถานะออฟไลน์


<a href=xxxx/xxxx.php?$user_edit=<?php echo $user_id ?>>แก้ไขข้อมูล</a>


xxx.php

$user_id=$_GET['user_id'];
$SQL="select*from account where user_id=$user_id ";
$rs=$db->Execute($SQL) or die(ERROR);
while(!$rs->EOF){
  $result=$rs->fields;
    $user=$result[username];
    $pass=$result[password];
$rs->MoveNext();

}


คร่าวนะครับลองประยุกต์ดูครับมีอาไรก็โพสมาครับถ้าตอบได้จะตอบแต่ถ้าตอบไม่ได้ก็ต้องรอท่านอื่นละครับ อิ อิ






Date : 2010-06-07 16:01:54 By : sleepington
 


 

No. 2



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณครับ

แต่ผมใช้ ASP.net อ่ะครับ
Date : 2010-06-07 16:13:03 By : ang89gunner
 

 

No. 3



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


Quote:
ซึ่งถ้า จะเข้าไปแก้ไข ข้อมูลส่วนตัว Session("userid") <> "" ครับ จึงสามารถเข้าไปได้


อ้าวไหงทำงั้นล่ะครับ แล้วจะรู้ได้ไงว่าจะแก้ของใคร
Date : 2010-06-07 16:15:20 By : tungman
 


 

No. 4



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


Code (PHP)
<a href=xxxx/xxxx.php?$user_edit=<?php echo $user_id ?>>แก้ไขข้อมูล</a>


xxx.php

$user_id=$_GET['user_id'];
$SQL="select*from account where user_id=$user_id ";
$rs=$db->Execute($SQL) or die(ERROR);
while(!$rs->EOF){
  $result=$rs->fields;
    $user=$result[username];
    $pass=$result[password];
$rs->MoveNext();

}

ไม่เห็นเกี่ยวกับแก้ user profile เลยครับ มีแค่ link ที่เขียนว่าแก้ไข แต่ด้านล่างมันเป็นการ

query ข้อมูลธรรมดา แบบใช้ recordset ด้วย ของ .net พัฒนาไปไกลแล้วครับไม่ใช้หรอก

rs เนี่ย เสียลูป กิ้ว กิ้ว
Date : 2010-06-07 16:32:54 By : tungman
 


 

No. 5



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


Quote:
ซึ่งถ้า จะเข้าไปแก้ไข ข้อมูลส่วนตัว Session("userid") <> "" ครับ จึงสามารถเข้าไปได้



อ้าวไหงทำงั้นล่ะครับ แล้วจะรู้ได้ไงว่าจะแก้ของใคร

แบบว่า ถ้า Session("userid") <> ""
ถ้า Session("userid") ไม่เท่ากับค่าว่าง ก็แสดงว่า มีค่าเก็บอยู่จึงสามารถ เข้า page แก้ไขข้อมูลส่วนตัวได้ครับ


แต่ผม ไม่รู้จะเขียน Code ให้ ข้อมูลที่อยู่ใน SQL มาโชว์ ใน Textbox ที่เตรียมไว้ยังไงอ่ะครับ
Date : 2010-06-07 17:00:09 By : ang89gunner
 


 

No. 6



โพสกระทู้ ( 1,603 )
บทความ ( 1 )



สถานะออฟไลน์


เพื่อนพี่ตึ๋งปะนั่นอะ คนนึงกวน อีกคนทั้งเมาทั้งมั่ว
คุณอ่านนิยามของ session ยังคะ หัวข้อมันคือ state management
session จะเป็นของใครของมัน ณ ขณะที่คุณเชื่อมต่อเข้าสู่ระบบค่ะ
user จะรับรู้เฉพาะ session ของตัวเอง เพราะ IIS บริหารจัดการมาแบบนี้ค่ะ

เนื่องจาก session มีคุณสมบัติแบบนั้นเราเลยมักเก็บค่าต่างของ user
คนปัจจุบันไว้ที่นี่กัน

Session("userid") <> ""
มันหมายความว่า มี attribute ชื่อ userid ที่จัดเก็บใน session แล้วมันมีค่า
ทีนี้คุณเอาไปตรวจสอบกับฐานข้อมูลจะแก้ไขอะไรก้อทำ page interface มา

เอ๋ถามเหมือนไม่ได้เขียนโค้ดเองหรือเปล่าลองพิจารณาดีๆค่ะ

แล้วคุณคนเมาๆนั่นอะ
ไปพักมั่งนะคะ
เดี๋ยวมาผิดทางอีก

Date : 2010-06-07 17:48:33 By : blurEyes
 


 

No. 7



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


ขออภัยด้วยครับ
ผมเขียนเองครับ บวกกับ ไปหาข้อมูลมา แล้วนำมา ใส่บ้าง

อย่าอันนี้จะเป็น Code Login ของผม ซึ่ง ก็เคยถาม ในเว็ปมาแล้ว ปรากฎ มีคน นำมาให้ครับ ผมก็ได้แก้ไข บางค่า กับ ค่า session
Code (VB.NET)
Imports System.Data.SqlClient
Imports System.Web.Security

Partial Class Login_Login
    Inherits System.Web.UI.Page

    Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click

        If IsUser() Then
            Response.Redirect("../userprofile.aspx")
        Else
            MessageBox("Invalid Username & Password", "LoginFail")
            If member() Then
                Response.Redirect("../userprofile.aspx")
            Else
                MessageBox("Invalid Username & Password", "LoginFail")
            End If
        End If
    End Sub
    'Admin
    Protected Function IsUser() As Boolean
        Dim HaveUser As Boolean = False
        Dim user As Integer = 0
        Dim connectionString As String = "Data Source=DELL_BLUE-PC;Initial Catalog=Research;Integrated Security=SSPI;"
        Dim objConnection As New SqlConnection(connectionString)

        Dim commandString As String = "Select Count(*) From [admid] Where [Username]=@Username And [Password]=@Password"
        Dim objCommand As New SqlCommand(commandString, objConnection)
        objCommand.Parameters.AddWithValue("@Username", txtUsername.Text)
        objCommand.Parameters.AddWithValue("@Password", txtPassword.Text)

        Try
            objConnection.Open()
            user = CInt(objCommand.ExecuteScalar())
            objCommand.Clone()

            If user > 0 Then
                HaveUser = True
                Session("userid") = txtUsername.Text
                Session.Timeout = 20
            End If
        Catch ex As Exception
            MessageBox(String.Format("Error: {0}", ex.Message), "ErrorMessage")
            Exit Try
        End Try

        Return HaveUser
    End Function
    'member
    Protected Function member() As Boolean
        Dim HaveUser As Boolean = False
        Dim user As Integer = 0
        Dim connectionString As String = "Data Source=DELL_BLUE-PC;Initial Catalog=Research;Integrated Security=SSPI;"
        Dim objConnection As New SqlConnection(connectionString)

        Dim commandString As String = "Select Count(*) From [Mem_Normal] Where [Username]=@Username And [Password]=@Password"
        Dim objCommand As New SqlCommand(commandString, objConnection)
        objCommand.Parameters.AddWithValue("@Username", txtUsername.Text)
        objCommand.Parameters.AddWithValue("@Password", txtPassword.Text)

        Try
            objConnection.Open()
            user = CInt(objCommand.ExecuteScalar())
            objCommand.Clone()

            If user > 0 Then
                HaveUser = True
                Session("userid") = txtUsername.Text
                Session.Timeout = 20
            End If
        Catch ex As Exception
            MessageBox(String.Format("Error: {0}", ex.Message), "ErrorMessage")
            Exit Try
        End Try

        Return HaveUser
    End Function

    Protected Sub MessageBox(ByVal Message As String, ByVal MessageName As String)
        Dim ClientScript As ClientScriptManager = Page.ClientScript

        If Not ClientScript.IsClientScriptBlockRegistered(Me.GetType(), MessageName) Then
            ClientScript.RegisterClientScriptBlock(Me.GetType(), MessageName, String.Format("alert('{0}')", Message), True)
        End If
    End Sub
End Class


Code (ASP)
<%@ Page Title="Login" Language="VB" MasterPageFile="~/MasterPage/MasterPage.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login_Login" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<center>

    <div style="height: 185px">
        <div style="position: relative; margin: 12px 12px 12px 12px; width: 250px;">  
            <div style="background: URL(../img/BDlogin/greenTop.gif) repeat-x top; position: absolute; left: 0px; top: -12px; height: 12px; width: 100%;"></div>  
            <div style="background: URL(../img/BDlogin/greenTopLeft.gif) no-repeat left top; position: absolute; left: -12px; width: 12px; top: -12px; height: 12px;"></div>  
            <div style="background: URL(../img/BDlogin/greenTopRight.gif) no-repeat right top; position: absolute; right: -12px; width: 12px; top: -12px; height: 12px;"></div>  
            <div style="background: URL(../img/BDlogin/greenLeft.gif) repeat-y left; position: absolute; left: -12px; width: 12px; top: 0px; bottom: 0px; height: 100%; _height: expression(eval(this.parentNode.clientHeight) + 'px');"></div>  
            <div style="background: URL(../img/BDlogin/greenRight.gif) repeat-y right; position: absolute; right: -12px; width: 12px; top: 0px; bottom: 0px; height: 100%; _height: expression(eval(this.parentNode.clientHeight) + 'px');"></div>  
            <div style="background: URL(../img/BDlogin/greenBottom.gif) repeat-x bottom; position: absolute; left: 0px; bottom: -12px; height: 12px; width: 100%;"></div>  
            <div style="background: URL(../img/BDlogin/greenBottomLeft.gif) no-repeat left bottom; position: absolute; left: -12px; width: 12px; bottom: -12px; height: 12px;"></div>  
            <div style="background: URL(../img/BDlogin/greenBottomRight.gif) no-repeat right bottom; position: absolute; right: -12px; width: 12px; bottom: -12px; height: 12px;"></div>  
            <div style="padding: 4px;">
                <div>
                    <span style="position: static; float: left;">
                        <asp:Label ID="lblUsername" runat="server" Text="UserName : " Height="21px"></asp:Label>                
                    </span>
                    <span style="position: static; float: right;">
                       <asp:TextBox ID="txtUsername" runat="server" Height="21px" Width="128px"></asp:TextBox>                
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="txtUsername"></asp:RequiredFieldValidator>
                    </span><br>                
                </div>
                <div style="clear: both; height: 5px;"></div>
                <div>
                    <span style="position: static; float: left;">
                        <asp:Label ID="lblPassword" runat="server" Text="Password : " Height="21px"></asp:Label>                
                    </span>
                    <span style="position: static; float: right;">
                        <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" 
                        Height="21px" Width="128px"></asp:TextBox>                
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="txtPassword"></asp:RequiredFieldValidator>
                    </span>  
                </div>
                <div style="clear: both; height: 10px;"></div>
                <div style="text-align: right;">
                    <asp:Button ID="btnLogin" runat="server" Text="Login" />
                </div>
            </div>  
        </div> 
    </div>
  

</center>
</asp:Content>


จะเห็นว่า ถ้าเกิด มีการ login สำเร็จ session จะมีการเก็บค่า Session("userid") = txtUsername.Text ไว้

ซึ่งผมจะเอา ค่านี้ไปใส่แต่ ละ Page เพื่อเช็ค เช่น Page ข้อมูล ที่อนุญาติเฉพาะให้คนที่ login เข้าได้เท่านั้น
ผมจะใส่ไว้ที่ page load
ว่าCode (VB.NET)
If (Session("userid") = "") Then
            Me.lbl1.Text = "กรุณาเข้าระบบ"
            Response.AppendHeader("Refresh", "5; URL=../login/login.aspx")


ที่ผมเอา If (Session("userid") <> "") Then ก็เพราะ

ถ้า Session มีค่า ก็ให้ โชว์ ข้อมูลที่อยุ่ใน SQL นำมาโชว์ใน testbox ครับ

ผมเข้าใจ ผิดรอครับ ถ้าผิด ผมขอโทษ ด้วยนะ ครับ
Date : 2010-06-07 18:17:08 By : ang89gunner
 


 

No. 8



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


เล่นเอาวุ่นวายกันไปหมดเลยนะ ใช้ vb เขียนด้วย รู้ไหมคนที่เขียน vb 99.99% เป็นเกย์

เปลี่ยนมาเขียนด้วย c# ด้วยกันเถอะ

1. สร้าง MasterPage ขึ้นมาก่อนตั้งชื่อว่า MasterPage.master

MasterPage.master
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<%@ Register TagPrefix="UserControls" TagName="LoginControl" Src="~/LoginUserControl.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body class="thrColFixHdr">
    <form id="form1" runat="server">
    <div>
        <div style="border: 1px solid black; padding: 10px;">
            <h1>Header</h1>
        </div>
        <div>
            <div style=" border-right: 1px solid black; border-left: 1px solid black; width: 200px; float: left; padding: 10px;">
                Menu
            </div>
            <div style="width: 400px; float: left; padding: 10px;">
                <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>                    
            </div>
            <div style="width: 200px; float:right; border-right: 1px solid black; border-left: 1px solid black; padding: 10px;">
               <UserControls:LoginControl ID="LoginControl" runat="server"></UserControls:LoginControl>
            </div>
        </div>
        <div style="clear: both; border: 1px solid black; padding: 10px;">
            Footer
        </div>
    </div>
    </form>
</body>
</html>

Date : 2010-06-07 22:01:42 By : tungman
 


 

No. 9



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


2. สร้าง web form ชื่อ Login.aspx ติ๊กที่ select master page แล้วใช้ MasterPage.master เป็น master page

MasterPage.master
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Label1" runat="server" Text="Please Login."></asp:Label>
</asp:Content>

Date : 2010-06-07 22:03:47 By : tungman
 


 

No. 10



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


3. สร้าง user control ในส่วนของ login ตั้งชื่อว่า LoginUserControl.ascx

LoginUserControl.ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="LoginUserControl.ascx.vb" Inherits="LoginUserControl" %>

LoginUserControl.ascx.vb
Imports System.Data
Imports System.Data.SqlClient

Partial Class LoginUserControl
    Inherits System.Web.UI.UserControl

    Private userTextBox As TextBox
    Private passwordTextBox As TextBox

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        userTextBox = New TextBox()
        passwordTextBox = New TextBox()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("UserID") Is Nothing Then
            CreateLoginForm()
        Else
            UserProfile()
        End If
    End Sub

    Protected Sub loginButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim strConnection As String = "Data Source=.\SQLEXPRESS;Initial Catalog=SqlDatabase;Integrated Security=True"
        Dim Connection As New SqlConnection(strConnection)

        Dim strCommand As String = "Select [UserID] From [UserTable] Where [UserName]=@UserName And [UserPassword]=@UserPassword"
        Dim Command As New SqlCommand(strCommand, Connection)
        Command.Parameters.AddWithValue("@UserName", userTextBox.Text)
        Command.Parameters.AddWithValue("@UserPassword", passwordTextBox.Text)

        Dim UserID As Integer = 0

        Try
            Connection.Open()
            Dim dataReader As SqlDataReader = Command.ExecuteReader(CommandBehavior.SingleRow)
            dataReader.Read()
            UserID = CInt(dataReader("UserID"))
            dataReader.Close()
            Connection.Close()
        Catch ex As Exception
            MessageBox.Show(String.Format("Error: {0}", ex.Message))
        End Try

        If UserID > 0 Then
            Session("UserID") = UserID

            Response.Redirect("~/LoginSuccess.aspx")
        Else
            Session("UserID") = Nothing

            MessageBox.Show("User Name หรือ Password ไม่ถูกต้อง")
        End If
    End Sub

    Protected Sub logoutButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Session("UserID") = Nothing

        Response.Redirect("~/Login.aspx")
    End Sub

    Protected Sub CreateLoginForm()
        Dim userLabel As New Label()
        userLabel.Text = "User:"
        Me.Controls.Add(userLabel)

        Me.Controls.Add(userTextBox)

        Me.Controls.Add(New LiteralControl("<br />"))

        Dim passwordLabel As New Label()
        passwordLabel.Text = "Password:"
        Me.Controls.Add(passwordLabel)

        passwordTextBox.Width = 120
        passwordTextBox.TextMode = TextBoxMode.Password
        Me.Controls.Add(passwordTextBox)

        Me.Controls.Add(New LiteralControl("<br />"))

        Dim loginButton As New Button()
        loginButton.Text = "Login"
        AddHandler loginButton.Click, New EventHandler(AddressOf loginButton_Click)
        Me.Controls.Add(loginButton)
    End Sub

    Protected Sub UserProfile()
        Dim strConnection As String = "Data Source=.\SQLEXPRESS;Initial Catalog=SqlDatabase;Integrated Security=True"
        Dim Connection As New SqlConnection(strConnection)

        Dim strCommand As String = "Select [UserName], [UserPassword] From [UserTable] Where [UserID]=@UserID"
        Dim Command As New SqlCommand(strCommand, Connection)
        Command.Parameters.AddWithValue("@UserID", CInt(Session("UserID")))

        Dim UserName As String = String.Empty

        Try
            Connection.Open()
            Dim dataReader As SqlDataReader = Command.ExecuteReader(CommandBehavior.SingleRow)
            dataReader.Read()
            UserName = dataReader("UserName").ToString()
            dataReader.Close()
            Connection.Close()
        Catch ex As Exception
            MessageBox.Show(String.Format("Error: {0}", ex.Message))
        End Try

        Dim userLabel As New Label()
        userLabel.Text = String.Format("Welcome {0}", UserName)
        Me.Controls.Add(userLabel)

        Me.Controls.Add(New LiteralControl("<br />"))

        Dim editProfile As New HyperLink()
        editProfile.Text = "Edit Profile"
        editProfile.NavigateUrl = "~/EditProfile.aspx"
        Me.Controls.Add(editProfile)

        Me.Controls.Add(New LiteralControl("<br />"))

        Dim logoutButton As New Button()
        logoutButton.Text = "Loout"
        AddHandler logoutButton.Click, New EventHandler(AddressOf logoutButton_Click)
        Me.Controls.Add(logoutButton)
    End Sub
End Class

Date : 2010-06-07 22:05:28 By : tungman
 


 

No. 11



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


4. สร้าง web form ชื่อ LoginSuccess.aspx ติ๊กที่ select master page แล้วใช้ MasterPage.master เป็น master page

LoginSuccess.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="LoginSuccess.aspx.vb" Inherits="LoginSuccess" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Label1" runat="server" Text="Success"></asp:Label>
</asp:Content>

LoginSuccess.aspx.vb
Partial Class LoginSuccess
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("UserID") Is Nothing Then
            Response.Redirect("~/Login.aspx")
        End If
    End Sub
End Class

Date : 2010-06-07 22:06:24 By : tungman
 


 

No. 12



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


5. สร้าง web form ชื่อ EditProfile.aspx ติ๊กที่ select master page แล้วใช้ MasterPage.master เป็น master page

EditProfile.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="EditProfile.aspx.vb" Inherits="EditProfile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Label1" runat="server" Text="User:"></asp:Label>
    <asp:TextBox ID="userTextBox" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="Label2" runat="server" Text="Password:"></asp:Label>
    <asp:TextBox ID="passwordTextBox" TextMode="Password" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="Label3" runat="server" Text="Confirm:"></asp:Label>
    <asp:TextBox ID="confirmTextBox" TextMode="Password" runat="server"></asp:TextBox>
    <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator" ControlToValidate="passwordTextBox" ControlToCompare="confirmTextBox"></asp:CompareValidator>
    <br />
    <asp:Button ID="saveButton" runat="server" Text="Save" />
    <asp:Button ID="cancelButton" runat="server" Text="Cancel" />
</asp:Content>

EditProfile.aspx.vb
Imports System.Data
Imports System.Data.SqlClient

Partial Class EditProfile
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("UserID") Is Nothing Then
            Response.Redirect("~/Login.aspx")
        End If
    End Sub

    Protected Sub saveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveButton.Click
        Dim strConnection As String = "Data Source=.\SQLEXPRESS;Initial Catalog=SqlDatabase;Integrated Security=True"
        Dim Connection As New SqlConnection(strConnection)

        Dim strCommand As String = "Update [UserTable] Set [UserName]=@UserName, [UserPassword]=@UserPassword Where [UserID]=@UserID"
        Dim Command As New SqlCommand(strCommand, Connection)
        Command.Parameters.AddWithValue("@UserName", userTextBox.Text)
        Command.Parameters.AddWithValue("@UserPassword", passwordTextBox.Text)
        Command.Parameters.AddWithValue("@UserID", CInt(Session("UserID")))

        Try
            Connection.Open()
            Command.ExecuteNonQuery()
            Connection.Close()
        Catch ex As Exception
            MessageBox.Show(String.Format("Error: {0}", ex.Message))
        End Try

        MessageBox.Show("อัฟเดตข้อมูลเรียบร้อย")

        Session("UserID") = Nothing
        Response.Redirect("~/Login.aspx")
    End Sub

    Protected Sub cancelButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cancelButton.Click
        Response.Redirect("~/LoginSuccess.aspx")
    End Sub
End Class


โค้ดห่วยบรมเลย เพราะไม่ใช่ full oop
Date : 2010-06-07 22:08:35 By : tungman
 


 

No. 13



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ลืมให้ดู database เลย ชื่อ UserTable

1

ปล. ลองเอาไปรัน แล้วศึกษาเป็นตัวอย่าง เดี๋ยวจะลบแล้ว เพราะไม่อยากให้เครื่องติด

ไวรัสตับอับเสบ (VB)
Date : 2010-06-07 22:10:55 By : tungman
 


 

No. 14



โพสกระทู้ ( 1,603 )
บทความ ( 1 )



สถานะออฟไลน์


Quote:
เล่นเอาวุ่นวายกันไปหมดเลยนะ ใช้ vb เขียนด้วย รู้ไหมคนที่เขียน vb 99.99% เป็นเกย์

เปลี่ยนมาเขียนด้วย c# ด้วยกันเถอะ


ถ้าพราวไปเขียน vb มั่ง พราวจะเป็นเกย์ปะคะ
Date : 2010-06-07 22:44:43 By : blurEyes
 


 

No. 15



โพสกระทู้ ( 87 )
บทความ ( 0 )



สถานะออฟไลน์


Quote:
เล่นเอาวุ่นวายกันไปหมดเลยนะ ใช้ vb เขียนด้วย รู้ไหมคนที่เขียน vb 99.99% เป็นเกย์

เปลี่ยนมาเขียนด้วย c# ด้วยกันเถอะ


่อ่าว ชิปหายแล้วตูเป็นเกย์เหรอเนี๊ย อุ๊ยตายว๊ายกรีดดด ไม่จริง
Date : 2010-06-08 04:51:24 By : AnimalMan
 


 

No. 16



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


แก้ข่าวครับผมไม่ได้เป็นเกย์ นะ ชาย แท้ครับ

ขอบคุณนะครับ

แต่มัน error ตรง MessageBox.Show รู้สึกมันจะ ใช้ MessageBox.Show เลยไม่ได้อ่ะครับ
Date : 2010-06-08 08:09:32 By : ang89gunner
 


 

No. 17



โพสกระทู้ ( 198 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

เฮ้อ webapp นี่เค้าใช้ messagebox.show ได้ซะที่ไหนล่ะท่าน
เขียนดีนะ แต่มาดันตกมาตาย
Date : 2010-06-08 18:30:57 By : anucham
 


 

No. 18



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


จริงดิ ตกหมาตายจริงๆ ด้วย

พอดีเขียน class messagebox เอาไว้แหละ แต่ไม่ได้เอามาลง อิอิ

ต้นฉบับเป็น c# แต่ลอง convert เป็น vb ให้แล้วกัน

MessageBox.vb
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Imports System.Collections
Imports System.Text

''' <summary>
''' Summary description for MessageBox
''' </summary>
Public Class MessageBox
	Private Shared m_executingPages As New Hashtable()

			'
			' TODO: Add constructor logic here
			'
	Public Sub New()
	End Sub

	Public Shared Sub Show(sMessage As String)
		' If this is the first time a page has called this method then
		If Not m_executingPages.Contains(HttpContext.Current.Handler) Then
			' Attempt to cast HttpHandler as a Page.
			Dim executingPage As Page = TryCast(HttpContext.Current.Handler, Page)

			If executingPage IsNot Nothing Then
				' Create a Queue to hold one or more messages.
				Dim messageQueue As New Queue()
				' Add our message to the Queue
				messageQueue.Enqueue(sMessage)
				' Add our message queue to the hash table. Use our page reference
				' (IHttpHandler) as the key.
				m_executingPages.Add(HttpContext.Current.Handler, messageQueue)
				' Wire up Unload event so that we can inject
				' some JavaScript for the alerts.
				AddHandler executingPage.Unload, New EventHandler(AddressOf ExecutingPage_Unload)
			End If
		Else
			' If were here then the method has allready been
			' called from the executing Page.
			' We have allready created a message queue and stored a
			' reference to it in our hastable.
			Dim queue As Queue = DirectCast(m_executingPages(HttpContext.Current.Handler), Queue)
			' Add our message to the Queue
			queue.Enqueue(sMessage)
		End If
	End Sub

	' Our page has finished rendering so lets output the
	' JavaScript to produce the alert's
	Private Shared Sub ExecutingPage_Unload(sender As Object, e As EventArgs)
		' Get our message queue from the hashtable
		Dim queue As Queue = DirectCast(m_executingPages(HttpContext.Current.Handler), Queue)

		If queue IsNot Nothing Then
			Dim sb As New StringBuilder()
			' How many messages have been registered?
			Dim iMsgCount As Integer = queue.Count
			' Use StringBuilder to build up our client slide JavaScript.
			sb.Append("<script language='javascript'>")
			' Loop round registered messages
			Dim sMsg As String

			While System.Math.Max(System.Threading.Interlocked.Decrement(iMsgCount),iMsgCount + 1) > 0
				sMsg = DirectCast(queue.Dequeue(), String)
				sMsg = sMsg.Replace(vbLf, "\n")
				sMsg = sMsg.Replace("""", "'")
				sb.Append("alert( """ & sMsg & """ );")
			End While
			' Close our JS
			sb.Append("</script>")
			' Were done, so remove our page reference from the hashtable
			m_executingPages.Remove(HttpContext.Current.Handler)
			' Write the JavaScript to the end of the response stream.
			HttpContext.Current.Response.Write(sb.ToString())
		End If
	End Sub
End Class


ให้เอาสร้าง class ชือ MessageBox.vb แล้วไปวางไว้ใน app_code นะจ๊ะ
Date : 2010-06-08 20:33:49 By : tungman
 


 

No. 19



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


คราวนี้ก็มี MessageBox.Show ใช้แบบ win app แล้ว โย้ว โย้ว

ไหนๆ แล้วก็นะ ขอมาม่านิดนึงก็แล้วกัน ไม่มี MessageBox.Show ก็เขียนเอาดิครับ
Date : 2010-06-08 20:34:36 By : tungman
 


 

No. 20



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณครับ เดียวจะลอง ทำดูครับ
Date : 2010-06-08 20:35:16 By : ang89gunner
 


 

No. 21



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


พี่ครับ พอดีช่วงนี้ติด ช่วยงาน พึ่งกลับมา

ลองดู Database พี่มี UserID ด้วย ไม่ทราบว่า
ต้องใส่ค่าเป็นอะไรครับ เพราะ พอสร้าง ฐานข้อมูลแล้ว มันเป้นค่าว่างไม่ได้

แล้ว ปกติผมมี สมัครสมาชิก แล้วไอ้ UserId อ่ะครับ ต้องใส่เป็นอะไร
Date : 2010-06-14 16:19:58 By : ang89gunner
 


 

No. 22



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


1
Date : 2010-06-14 16:35:27 By : tungman
 


 

No. 23



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณครับผม

พี่เยี่ยมจริงๆ
Date : 2010-06-14 16:54:56 By : ang89gunner
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : พี่ครับ ช่วยอธิบายการทำให้user แก้ไข ข้อมูลส่วนตัว หลัง จาก login แล้วหน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่