Hey Guys,

Got a question on storing a value from protcted method to a public variable then using that public variable(with value from protcted method) in another protcted method.. My explaination, so I'll show my code. I'm new to coding so pls be easy on me.. You help is appreciate a million!! Thanks!! :]

Partial Class test
    Inherits System.Web.UI.Page
    Dim TempVal As String = ""

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim startVal As String = "Welcome"
        TempVal = startVal
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Response.Write("val is " & TempVal)
    End Sub
End Class

Recommended Answers

All 2 Replies

What's your question?

I want to be able to display "Welcome" when i click button 2.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.