How generate the unique no. 1,2,3 and so on .... on button click of each new user ..
the code mentioned below is a readwrite coding in vb.net ...
but the problem is it generate the same id for different users on button click event... but i want the no. of times button clicked the new ids will be generated
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FILE_NAME As String = Server.MapPath("counts.vbi")
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write(Literal1.Text)
objWriter.Close()
Else
End If
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Dim FILE_NAME As String = 开发者_高级运维Server.MapPath("counts.vbi")
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objStreamReader As New System.IO.StreamReader(FILE_NAME)
Literal1.Text = objStreamReader.ReadToEnd
Literal1.Text += 1
objStreamReader.Close()
End If
End Sub
You can generate Random Id like this :
Guid.NewGuid().ToString("N")
Hope This can Help You.
Thanks
精彩评论