How I could Make user controls to take The new value from updated web form page?

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
mazazeek
8/27/2005 11:09:47 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

9 Replies
884 Views

Similar Articles

[PageSpeed] 7

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
codeasp
8/28/2005 6:53:50 AM

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 Integer

Get

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.Init

userinfo.members_no=1
End Sub

and 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
mazazeek
8/28/2005 8:32:02 AM
Up
0
mazazeek
8/28/2005 5:41:22 PM
Please post your relevant code - especially the Usercontrol declaration in the page and your useage of it.
0
codeasp
8/28/2005 11:24:16 PM

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 SqlCommand

userinfo = 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 Function

End 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.Init

        If Not Page.IsPostBack Then

            membersinfo()
        End If

        InitializeComponent()
    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 Then

            Dim 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 Sub

End Class
=================================
Public Class header1
    Inherits System.Web.UI.UserControl

    Protected 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 Sub

End Class
======================================================================================

0
mazazeek
8/29/2005 1:11:37 AM
Up
0
mazazeek
8/29/2005 6:58:45 PM

Up

0
mazazeek
8/30/2005 8:29:35 PM
No any one you can help me????????????????????
0
mazazeek
8/31/2005 12:01:40 PM

I am solve this problem by using cache.

Thanks for all

0
mazazeek
8/31/2005 10:33:11 PM
Reply:

Similar Artilces:

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Retreiving a value from a web form within a web user control
Hi  I have a page (web form) that retreives some data from a database. To be more specific: at some point when user clicks a button (in the web form) there is some ID number retreived from a database in code behind. At the same time the Visible property of the nestet web user control is chamged to true. I want than forward the ID to the web user control so that a grid view can load data from a database for that ID. How can I access that data (the ID) within a web user control context nested in that page?  Kind regards   Check this ;ink  http://www.codeproject.com/K...

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: http://msdn2.microsoft.com/en-us/library/ms178139.aspxAlso: http://msdn2.microsoft.com/en-us/library/ms178140.aspx might ...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Passing Values from a Web Form to Another Web Form
Hello All! I am trying to pass values from one web form to another web form. I know that there are 3 ways of doing this: queryString, Server.Transfer and Session. I am using the Server.Transfer method. But I am not able to create, in my 2nd web form, an instance of my 1st web form. My 1st Web form is named CallTrack.aspx and my 2nd is named Export.aspx. What I mean is something like this: Public value as CallTrack. I can't create it in my 2nd web form because when the intellisense is displayed, there's no CallTrack in the options. Thanks!   How about using cross-...

custom web user control and web form
Guys,          I am trying to develop a context menu control for all of my pages. what i am trying to do is that i want the control to pick a datasource from the markup and then check whether its an xml file or a datatable. I created a class called datasource.   /**************************DataSource Class****************************/  public class DataSource { /// <summary> /// This is to identify unique elements from the markup /// </summary>protected string _ID; /// <summary> /// This will be the Datasource ID e...

Clearing Web Controls Values from a Web Form
I have a web form and after a user submit it I want to clear the form so that they may submit another entry. I have seen examples in VB of how to loop thru a web form and clear the controls, but I need a C# solution. I have tried the following code, while it does not give me an error, it does not clear the controls on the form. Any suggestions? Thanks! foreach (Control parent in Page.Controls)         {             foreach (Control child in parent.Controls)           ...

Web User Control Not rendering in Web Form
I have created a Web User control that is made up of a Multiview with 2 views inside the Multiview. I have buttons on both views and a gridview on 1 view. My question is when I drop this Web User Control on a Web Form all I see is [MultiView"MultiView1"] and when I view the from in the browser I dont see the Web User Control. I was wondering if someone could please tell me why the Web User Control is not displaying or rendering.     Thanks In Advance Hi, Please check your aspx file for correct reference, like following example: TestControl.ascx:<%@ Control ...

Single page with multiple user web controls VS Multiple page with specific user web controls
I have a question regarding single page with multiple user web controls vs multiple page with specific user web controls   Option 1: I am of the opinion to have multiple pages with specific user web controls and use an object to store all the information as the user navigates through the application. And finally at the end, read this object and save all the information to the backend database.   Option 2: My respected team member suggests that we have only one page, with all the specific user web controls and not use an object, instead show/hide the user web controls based ...

Solution for web forms that look just like paper forms ? User controls ? Adobe fillable forms ?
 I am looking at ways to web-enable a series of company forms that need to have the form itself look just like the paper version.  It would be great if I could use an image of the form itself as a background, and then draw the UI components on top of this.  Then there is the question of printing these forms complete with the data that was filled in.   What are some options for doing this kind of application ?  Im open to 3rd party solutions as well.  Our company currently has a desktop application which does this, but I want to come up with a web based solu...

Open web page in IE and populate fields on the form from my web form
To the dot net Knights.  Many humble thanks in advance from a dot net surf. We have an vb application that opens multiple instances of IE object, each to different web pages.  It then takes information from the current record in the app, populates fields on each of the web pages, and them submits the forms.  We are then able to look at the resulting web pages and quickly get the info we're looking for.This prevents us from having to manually navigate to each web site, enter the same information and then wait for the page to open.  If there is ...

Access SqlDataSource on Web Form from a Web User Control...
Hello, I want to access a SqlDataSource on a Web Form fromout. a Web User Control. To do this, I have in my code behind of the Web User Control the folowing code: DropDownList1.DataSource = (this.Page.FindControl("SqlDataSource3") as SqlDataSource);DropDownList1.DataTextField = "Name;DropDownList1.DataValueField = "NameIDropDownList1.DataBind(); But, the control (ic. SqlDataSource3) is not found. Even other controls like labels and buttons are not found with the FindControl. What am I doing wrong? Thanks Andromedaris     This is not much of a surprise,...

Pass data from Web User Control to Web Form
I have a Web Form that contains a Web User Control. The WUC displays dynamic content. I want to change the TITLE property of the Web Form, based on the contents of the WUC. For example, if the WUC displays information about Horses, I want to change the page title to "HORSES" by passing the string to the parent Web Form. I have tried playing with parameters and such, but I can't remember how I did this in the past. PLEASE HELP!~o0 Spin-Monkey Oo~ The best way to do this is by creating a public property on your web user control and accessing that from your web form. Check ...

Web resources about - How I could Make user controls to take The new value from updated web form page? - asp.net.web-forms

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Now you can control your GoPro Camera from Apple Watch
One of the nicest features of the GoPro camera is the ability to control it using the iPhone app. With the GoPro App , you can easily control ...

Control a car's features with a glance? Not science fiction
Filed under: Emerging Technologies , Infotainment , Technology Press a button to change your car's climate controls? Turn a knob to view your ...

Arizona leaders welcome 'Leave No Child Behind' successor, less federal control
azcentral.com Arizona leaders welcome 'Leave No Child Behind' successor, less federal control azcentral.com The Senate gave final approval ...

FTC and healthcare cost control
... Pennsylvania, and lead to reduced quality and higher health care costs for the area’s employers and residents….the merged entity would control ...

Google seems more determined than ever to take control of Android
... to ad money. However, Google grabbed the lion’s share of the smartphone market by giving Android away. That means it lost the ability to control ...

How to control your iPhone by just tilting your head
... the best sight, hearing, or motor functions to still use iOS to its fullest capabilities — but they can also be used to customize your controls. ...

Fox Presents Ben Stein As An Awesome, Stupendous Gun Control Genius
Fox News host Neil Cavuto was super-impressed with “great writer and thinker” Ben Stein's opposition to gun control. “The problem is not gun ...

White House: We’re Not Going To Wait Until Something Happens To Pass Gun Control
Reporter: 'Where any of the recent mass shooters on the no-fly list?' Earnest: 'Not that I'm aware of'

The NFL Should Seize Control Of The Cleveland Browns
Drew Magary’s Thursday Afternoon NFL Dick Joke Jamboroo runs every Thursday during the NFL season. Email Drew here . Read more...

Resources last updated: 12/11/2015 2:52:15 AM