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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Web User controls, with buttons

Status
Not open for further replies.

GMillsy

Programmer
Jan 5, 2003
3
CA
I am trying to get a .ASPX page for users to signup/login to. And I decided to make multiple Web User controls to just switch between with the .visible property.

Works great for the controls that don't have any dynamic content like buttons. But on any of the controls that have buttons whenever they are pressed, it loads up the default page. I have gotten it so that the controls have a property of "has_control" that is set to true whenever they should be the page displayed (ie: their job is not done) and a button on the main page, can check to see which needs displaying, and reload that control (all be it, with all the fields blanked out, but I can deal with that)

I thought that the page_load() Sub ran on the main .aspx page every time something like a button was pressed on a control. But for some reason, the same code that is being run with the button on the main page, does not get run when it is in the Page_load sub.

Any help?
 
This code is in the main .aspx file.

Note, textbox1 is just something I put on to try and see if any code was being run. It normally will not, unless like I said before, I put the code that is in page_load, into a button.click event on the main page. I've also made sure than non of the other pages conflict when it comes to "having control"

Protected WithEvents page_signup As cust_signup
Protected WithEvents page_default As _Default


Private Sub clear_page()
'clears the page
page_default.Visible = False
page_signup.Visible = False

end sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


clear_page()

'checks for pages that are currently working on something, if not, displays the default page
If (page_signup.Has_control = true)Then
page_signup.Visible = True
TextBox1.Text = "Page Signup"
page_signup.Has_control = 1
ElseIf (page_contact.Has_control = True) Then
page_contact.Visible = True
TextBox1.Text = "Page contact"
ElseIf (page_login.Has_control = True) Then
page_login.Visible = True
TextBox1.Text = "page_login"
Else
Default_page()
TextBox1.Text = "Page default"
End If


======================

This code is from the "cust_signup" control (.ascx)
======================
Private control As Boolean = False

Public Property Has_control() As Boolean
Get
Return control

End Get
Set(ByVal Value As Boolean)
control = Value

End Set
End Property

Private Sub cmd_submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_submit.Click

Me.Has_control = True

If (txt_signPass.Text <> txt_passConferm.Text) Then
required.Visible = False
Match.Visible = True
Me.Has_control = True
'also tried &quot;control = true&quot;
Else
Match.Visible = False
required.Visible = False

Me.Has_control = False
End If

 
Well, I fixed the problem myself. But I'd like to let everyone else know what i did.


I changed the propertry code till it looked like this

==========================
Private control As Integer = 1
Public Property Has_control() As Integer

Get
Return viewstate(&quot;control&quot;)
End Get
Set(ByVal Value As Integer)
control = Value
viewstate(&quot;control&quot;) = Value

End Set
End Property
==========================
Then every time i needed to change the property from within the control, I would either use viewstate(&quot;control&quot;) = 1 or 0 (I know i know, but I'm going to leave it like that)
I access the property using the same code as before, just looking to see if it matches '1' instead of 'true'

Hope this helps someone later on. ^_^
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top