I am creating a webpart that will take ultimately take user information and display it in another web part or in a new window.
My problems are these:
1) I can't seem to figure out how to use a button to trigger an action in the web part.
Basically, I want to make is so that I push a button and it takes information and does fun stuff with it.
Public Class DBConnect
Inherits Microsoft.SharePoint.WebPartPages.WebPart
Private Const _defaultText As String = ""
Dim _text As String = _defaultText
Dim myLabel As Label
Protected Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write(SPEncode.HtmlEncode(Text))
myLabel = New Label
myLabel.ID = "label1"
myLabel.Text = "Hello World 3"
Controls.Add(myLabel)
myLabel.RenderControl(output)
output.Write("<br>")
Dim myButton As New Button
myButton.Text = "Test"
Controls.Add(myButton)
myButton.RenderControl(output)
AddHandler myButton.Click, AddressOf myButton_Click
End Sub
Private Sub myButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
myLabel.Text = "Test"
MsgBox("test!!")
End Sub
End Class
Sadly it doesnt do anything. it just blinks (reloads itself?).
2) Once I get the triggers working, is there an easy way to create a new window or set up a web part that will display this information? Even if I have to display it in the same webpart that would be fine. I just dont know how to refresh the page to display the information that I want it to show.
My problems are these:
1) I can't seem to figure out how to use a button to trigger an action in the web part.
Basically, I want to make is so that I push a button and it takes information and does fun stuff with it.
Public Class DBConnect
Inherits Microsoft.SharePoint.WebPartPages.WebPart
Private Const _defaultText As String = ""
Dim _text As String = _defaultText
Dim myLabel As Label
Protected Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write(SPEncode.HtmlEncode(Text))
myLabel = New Label
myLabel.ID = "label1"
myLabel.Text = "Hello World 3"
Controls.Add(myLabel)
myLabel.RenderControl(output)
output.Write("<br>")
Dim myButton As New Button
myButton.Text = "Test"
Controls.Add(myButton)
myButton.RenderControl(output)
AddHandler myButton.Click, AddressOf myButton_Click
End Sub
Private Sub myButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
myLabel.Text = "Test"
MsgBox("test!!")
End Sub
End Class
Sadly it doesnt do anything. it just blinks (reloads itself?).
2) Once I get the triggers working, is there an easy way to create a new window or set up a web part that will display this information? Even if I have to display it in the same webpart that would be fine. I just dont know how to refresh the page to display the information that I want it to show.