开发者

Unique number for unique visitor on button click in vb.net?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜