I have webform Page That I change values in classess throeugh it but on calling the "User control"pages It dosent responed to the changing the Question is How I could Make IT to take The new value from updated web form page? |
![]() |
0 |
![]() |
Declare a public property in the user control and set it from the page.
Example:
User control
Public Property ChangeName() As String
Get
return custName.text
End Get
Set (byval value as String)
custName.Text = value
End Set
End Property
In the page:
Protected WithEvents uc as Usercontrol
uc.ChangeName = "new name"
If you have any questions reply to the post.
![]() |
0 |
![]() |
Thank you codeasp for your reply,But I have class name userinfo and Declare a public property:
Private _members_no As Integer = 0
Public Property members_no() As IntegerGet
Return _members_no
End Get
Set(ByVal Value As Integer)
_members_no = Value
End Set
End Property
in the page i Change the Property members_no
Protected userinfo As New userinfo
private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Inituserinfo.members_no=1
End Suband I have usercontrols the class name in header,When i load the usercontrols in page the value returned is 0 not 1.
how When i change the value in the class userinfo by page,make the usercontrols get the value changed in class userinfo when load the usercontrols in the page.
![]() |
0 |
![]() |
Up
![]() |
0 |
![]() |
Please post your relevant code - especially the Usercontrol declaration in the page and your useage of it.
![]() |
0 |
![]() |
Public
Class userinfo '----------------------------- Private strConString As String = ConfigurationSettings.AppSettings("conString") Private conn As SqlConnection = New SqlConnection(strConString) '----------------------------- Private _members_no As Integer = 0 Private _stated As Char Private _have_new_message As Char Private _subscrip As Char = "N" Private _number_style As Integer = 1
Public Property members_no() As Integer Get Return _members_no End Get Set(ByVal Value As Integer)
_members_no = Value
End Set End Property Public Property stated() As Char Get Return _stated End Get Set(ByVal Value As Char)_stated = Value
End Set End Property Public Property have_new_message() As Char Get Return _have_new_message End Get Set(ByVal Value As Char)_have_new_message = Value
End Set End Property Public Property subscrip() As Char Get Return _subscrip End Get Set(ByVal Value As Char)_subscrip = Value
End Set End Property Public Property number_style() As Integer Get Return _number_style End Get Set(ByVal Value As Integer)_number_style = Value
End Set End Property '======================== Public Function getinfomembers(ByVal name As String, ByVal pass As String) As SqlDataReader Dim userinfo As SqlCommanduserinfo =
New SqlCommand("get_userinfo", conn)userinfo.CommandType = CommandType.StoredProcedure
userinfo.Parameters.Add("@username", SqlDbType.NVarChar, 30).Value = name
userinfo.Parameters.Add("@pass", SqlDbType.Binary, 16).Value = pass
conn.Open()
Return userinfo.ExecuteReader(CommandBehavior.CloseConnection) End FunctionEnd
Class
===========================================
Public Class default_page
Inherits System.Web.UI.Page
Private strConString As String = ConfigurationSettings.AppSettings("conString")
Private conn As SqlConnection = New SqlConnection(strConString)
Protected userinfo As New userinfo
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.InitIf Not Page.IsPostBack Then
membersinfo()
End IfInitializeComponent()
End Sub
Private Sub membersinfo()
Dim name As String
Dim Pwrod As String
Dim Name_Pword() As String
Dim user As SqlDataReader
If Not Request.Cookies("userinfo") Is Nothing ThenDim UserInfoCookieCollection As _
System.Collections.Specialized.NameValueCollection
UserInfoCookieCollection = Request.Cookies("userInfo").Values
Name_Pword = Split(general_function.killChars(UserInfoCookieCollection("Name_Pword")), ",")name = Name_Pword(0)
Pwrod = Name_Pword(1)
ElseIf Session("name") <> "" And Session("Pword") <> "" Then
name = Session("name")Pwrod = Session("Pword")
End If
If name <> "" And Pwrod <> "" Then
user = userinfo.getinfomembers(name, Pwrod)
If user.Read Then
userinfo.members_no = user("members_no")
userinfo.stated = user("stated")
userinfo.have_new_message = user("have_new_message")
generaldata.date_diff = user("hour_diff_with_gm")
generaldata.type_date = user("type_date")
userinfo.subscrip = user("subscrip")
userinfo.number_style = user("number_style")
End If
End If
End SubEnd Class
=================================
Public Class header1
Inherits System.Web.UI.UserControlProtected userinfo As New userinfo
Public page_now As String
Public usermembers_no As Integer
Public count_news As Integer
Public name As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
If userinfo.members_no = 0 Then
loginout.Visible = True
Else
login.Visible = True
End If
End If
End Sub
====================================================================================
Public Class header
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim userinfo As New userinfo
Dim ctheader As Control
ctheader = LoadControl("header" & userinfo.number_style & ".ascx")
Plheader.Controls.Add(ctheader)
End If
End SubEnd Class
======================================================================================
![]() |
0 |
![]() |
Up
![]() |
0 |
![]() |
Up
![]() |
0 |
![]() |
No any one you can help me????????????????????
![]() |
0 |
![]() |
I am solve this problem by using cache.
Thanks for all
![]() |
0 |
![]() |