Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WSS & VB.Net: Webparts with buttons and triggers.

Status
Not open for further replies.

andyd273

Programmer
Nov 2, 2005
21
0
0
US
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top