user control and databinding expression

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Oct 25, 2006.

  1. hey all,
    for simplicity's sake i have a single textbox inside a user control. once i
    drag that user control onto my page is there a way to attach a binding
    expression to it at runtime?

    thanks,
    rodchar
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 25, 2006
    #1
    1. Advertising

  2. User control can expose properties. You can make a property that will set
    the binding expression. Is it what you are after?

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "rodchar" <> wrote in message
    news:...
    > hey all,
    > for simplicity's sake i have a single textbox inside a user control. once
    > i
    > drag that user control onto my page is there a way to attach a binding
    > expression to it at runtime?
    >
    > thanks,
    > rodchar
    Eliyahu Goldin, Oct 25, 2006
    #2
    1. Advertising

  3. yes, i've exposed public properties in a user control but which one do i
    expose in this case. i couldn't find the DataBindings.Add for the textbox in
    my user control (with the context of being in the user control designer).

    i guess what i'm asking is what public property do i expose on the user
    control and how do i set it?

    thanks,
    rodchar

    "Eliyahu Goldin" wrote:

    > User control can expose properties. You can make a property that will set
    > the binding expression. Is it what you are after?
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    >
    > "rodchar" <> wrote in message
    > news:...
    > > hey all,
    > > for simplicity's sake i have a single textbox inside a user control. once
    > > i
    > > drag that user control onto my page is there a way to attach a binding
    > > expression to it at runtime?
    > >
    > > thanks,
    > > rodchar

    >
    >
    >
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 25, 2006
    #3
  4. Something like this?

    public string TextBinding
    {
    set
    {
    myText.Text = value;
    myText.DataBind();
    }
    }

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "rodchar" <> wrote in message
    news:...
    > yes, i've exposed public properties in a user control but which one do i
    > expose in this case. i couldn't find the DataBindings.Add for the textbox
    > in
    > my user control (with the context of being in the user control designer).
    >
    > i guess what i'm asking is what public property do i expose on the user
    > control and how do i set it?
    >
    > thanks,
    > rodchar
    >
    > "Eliyahu Goldin" wrote:
    >
    >> User control can expose properties. You can make a property that will set
    >> the binding expression. Is it what you are after?
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer & Consultant
    >> Microsoft MVP [ASP.NET]
    >>
    >>
    >> "rodchar" <> wrote in message
    >> news:...
    >> > hey all,
    >> > for simplicity's sake i have a single textbox inside a user control.
    >> > once
    >> > i
    >> > drag that user control onto my page is there a way to attach a binding
    >> > expression to it at runtime?
    >> >
    >> > thanks,
    >> > rodchar

    >>
    >>
    >>
    Eliyahu Goldin, Oct 25, 2006
    #4
  5. I'm not sure what i'm doing wrong:

    <uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
    "GetTime()" %>'></uc1:webusercontrol>

    defined on the .aspx:
    Public Function GetTime() As String
    Return DateTime.Now.ToString("T")
    End Function

    defined on the control page:
    Public Property UcTextBox() As String
    Get
    Return Me.TextBox1.Text
    End Get
    Set(ByVal value As String)
    Me.TextBox1.Text = value
    End Set
    End Property

    And the result is that nothing shows up in the textbox.

    "Eliyahu Goldin" wrote:

    > Something like this?
    >
    > public string TextBinding
    > {
    > set
    > {
    > myText.Text = value;
    > myText.DataBind();
    > }
    > }
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    >
    > "rodchar" <> wrote in message
    > news:...
    > > yes, i've exposed public properties in a user control but which one do i
    > > expose in this case. i couldn't find the DataBindings.Add for the textbox
    > > in
    > > my user control (with the context of being in the user control designer).
    > >
    > > i guess what i'm asking is what public property do i expose on the user
    > > control and how do i set it?
    > >
    > > thanks,
    > > rodchar
    > >
    > > "Eliyahu Goldin" wrote:
    > >
    > >> User control can expose properties. You can make a property that will set
    > >> the binding expression. Is it what you are after?
    > >>
    > >> --
    > >> Eliyahu Goldin,
    > >> Software Developer & Consultant
    > >> Microsoft MVP [ASP.NET]
    > >>
    > >>
    > >> "rodchar" <> wrote in message
    > >> news:...
    > >> > hey all,
    > >> > for simplicity's sake i have a single textbox inside a user control.
    > >> > once
    > >> > i
    > >> > drag that user control onto my page is there a way to attach a binding
    > >> > expression to it at runtime?
    > >> >
    > >> > thanks,
    > >> > rodchar
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 25, 2006
    #5
  6. call DataBind()

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "rodchar" <> wrote in message
    news:...
    > I'm not sure what i'm doing wrong:
    >
    > <uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
    > "GetTime()" %>'></uc1:webusercontrol>
    >
    > defined on the .aspx:
    > Public Function GetTime() As String
    > Return DateTime.Now.ToString("T")
    > End Function
    >
    > defined on the control page:
    > Public Property UcTextBox() As String
    > Get
    > Return Me.TextBox1.Text
    > End Get
    > Set(ByVal value As String)
    > Me.TextBox1.Text = value
    > End Set
    > End Property
    >
    > And the result is that nothing shows up in the textbox.
    >
    > "Eliyahu Goldin" wrote:
    >
    >> Something like this?
    >>
    >> public string TextBinding
    >> {
    >> set
    >> {
    >> myText.Text = value;
    >> myText.DataBind();
    >> }
    >> }
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer & Consultant
    >> Microsoft MVP [ASP.NET]
    >>
    >>
    >> "rodchar" <> wrote in message
    >> news:...
    >> > yes, i've exposed public properties in a user control but which one do
    >> > i
    >> > expose in this case. i couldn't find the DataBindings.Add for the
    >> > textbox
    >> > in
    >> > my user control (with the context of being in the user control
    >> > designer).
    >> >
    >> > i guess what i'm asking is what public property do i expose on the user
    >> > control and how do i set it?
    >> >
    >> > thanks,
    >> > rodchar
    >> >
    >> > "Eliyahu Goldin" wrote:
    >> >
    >> >> User control can expose properties. You can make a property that will
    >> >> set
    >> >> the binding expression. Is it what you are after?
    >> >>
    >> >> --
    >> >> Eliyahu Goldin,
    >> >> Software Developer & Consultant
    >> >> Microsoft MVP [ASP.NET]
    >> >>
    >> >>
    >> >> "rodchar" <> wrote in message
    >> >> news:...
    >> >> > hey all,
    >> >> > for simplicity's sake i have a single textbox inside a user control.
    >> >> > once
    >> >> > i
    >> >> > drag that user control onto my page is there a way to attach a
    >> >> > binding
    >> >> > expression to it at runtime?
    >> >> >
    >> >> > thanks,
    >> >> > rodchar
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
    Eliyahu Goldin, Oct 25, 2006
    #6
  7. sorry for just not getting it, but where do i from? (control page in the
    properties, on on the .aspx page) i tried in both places and i'm not getting
    anything?

    "Eliyahu Goldin" wrote:

    > call DataBind()
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    >
    > "rodchar" <> wrote in message
    > news:...
    > > I'm not sure what i'm doing wrong:
    > >
    > > <uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
    > > "GetTime()" %>'></uc1:webusercontrol>
    > >
    > > defined on the .aspx:
    > > Public Function GetTime() As String
    > > Return DateTime.Now.ToString("T")
    > > End Function
    > >
    > > defined on the control page:
    > > Public Property UcTextBox() As String
    > > Get
    > > Return Me.TextBox1.Text
    > > End Get
    > > Set(ByVal value As String)
    > > Me.TextBox1.Text = value
    > > End Set
    > > End Property
    > >
    > > And the result is that nothing shows up in the textbox.
    > >
    > > "Eliyahu Goldin" wrote:
    > >
    > >> Something like this?
    > >>
    > >> public string TextBinding
    > >> {
    > >> set
    > >> {
    > >> myText.Text = value;
    > >> myText.DataBind();
    > >> }
    > >> }
    > >>
    > >> --
    > >> Eliyahu Goldin,
    > >> Software Developer & Consultant
    > >> Microsoft MVP [ASP.NET]
    > >>
    > >>
    > >> "rodchar" <> wrote in message
    > >> news:...
    > >> > yes, i've exposed public properties in a user control but which one do
    > >> > i
    > >> > expose in this case. i couldn't find the DataBindings.Add for the
    > >> > textbox
    > >> > in
    > >> > my user control (with the context of being in the user control
    > >> > designer).
    > >> >
    > >> > i guess what i'm asking is what public property do i expose on the user
    > >> > control and how do i set it?
    > >> >
    > >> > thanks,
    > >> > rodchar
    > >> >
    > >> > "Eliyahu Goldin" wrote:
    > >> >
    > >> >> User control can expose properties. You can make a property that will
    > >> >> set
    > >> >> the binding expression. Is it what you are after?
    > >> >>
    > >> >> --
    > >> >> Eliyahu Goldin,
    > >> >> Software Developer & Consultant
    > >> >> Microsoft MVP [ASP.NET]
    > >> >>
    > >> >>
    > >> >> "rodchar" <> wrote in message
    > >> >> news:...
    > >> >> > hey all,
    > >> >> > for simplicity's sake i have a single textbox inside a user control.
    > >> >> > once
    > >> >> > i
    > >> >> > drag that user control onto my page is there a way to attach a
    > >> >> > binding
    > >> >> > expression to it at runtime?
    > >> >> >
    > >> >> > thanks,
    > >> >> > rodchar
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 25, 2006
    #7
  8. New Results - Re: user control and databinding expression

    ok i tried the databinding with a real datasource instead of the function and
    it worked. out of curiosity, is the function suppose to work and maybe my
    declaring syntax is incorrect?


    "rodchar" wrote:

    > sorry for just not getting it, but where do i from? (control page in the
    > properties, on on the .aspx page) i tried in both places and i'm not getting
    > anything?
    >
    > "Eliyahu Goldin" wrote:
    >
    > > call DataBind()
    > >
    > > --
    > > Eliyahu Goldin,
    > > Software Developer & Consultant
    > > Microsoft MVP [ASP.NET]
    > >
    > >
    > > "rodchar" <> wrote in message
    > > news:...
    > > > I'm not sure what i'm doing wrong:
    > > >
    > > > <uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
    > > > "GetTime()" %>'></uc1:webusercontrol>
    > > >
    > > > defined on the .aspx:
    > > > Public Function GetTime() As String
    > > > Return DateTime.Now.ToString("T")
    > > > End Function
    > > >
    > > > defined on the control page:
    > > > Public Property UcTextBox() As String
    > > > Get
    > > > Return Me.TextBox1.Text
    > > > End Get
    > > > Set(ByVal value As String)
    > > > Me.TextBox1.Text = value
    > > > End Set
    > > > End Property
    > > >
    > > > And the result is that nothing shows up in the textbox.
    > > >
    > > > "Eliyahu Goldin" wrote:
    > > >
    > > >> Something like this?
    > > >>
    > > >> public string TextBinding
    > > >> {
    > > >> set
    > > >> {
    > > >> myText.Text = value;
    > > >> myText.DataBind();
    > > >> }
    > > >> }
    > > >>
    > > >> --
    > > >> Eliyahu Goldin,
    > > >> Software Developer & Consultant
    > > >> Microsoft MVP [ASP.NET]
    > > >>
    > > >>
    > > >> "rodchar" <> wrote in message
    > > >> news:...
    > > >> > yes, i've exposed public properties in a user control but which one do
    > > >> > i
    > > >> > expose in this case. i couldn't find the DataBindings.Add for the
    > > >> > textbox
    > > >> > in
    > > >> > my user control (with the context of being in the user control
    > > >> > designer).
    > > >> >
    > > >> > i guess what i'm asking is what public property do i expose on the user
    > > >> > control and how do i set it?
    > > >> >
    > > >> > thanks,
    > > >> > rodchar
    > > >> >
    > > >> > "Eliyahu Goldin" wrote:
    > > >> >
    > > >> >> User control can expose properties. You can make a property that will
    > > >> >> set
    > > >> >> the binding expression. Is it what you are after?
    > > >> >>
    > > >> >> --
    > > >> >> Eliyahu Goldin,
    > > >> >> Software Developer & Consultant
    > > >> >> Microsoft MVP [ASP.NET]
    > > >> >>
    > > >> >>
    > > >> >> "rodchar" <> wrote in message
    > > >> >> news:...
    > > >> >> > hey all,
    > > >> >> > for simplicity's sake i have a single textbox inside a user control.
    > > >> >> > once
    > > >> >> > i
    > > >> >> > drag that user control onto my page is there a way to attach a
    > > >> >> > binding
    > > >> >> > expression to it at runtime?
    > > >> >> >
    > > >> >> > thanks,
    > > >> >> > rodchar
    > > >> >>
    > > >> >>
    > > >> >>
    > > >>
    > > >>
    > > >>

    > >
    > >
    > >
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 25, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    428
  2. Mad Scientist Jr
    Replies:
    0
    Views:
    626
    Mad Scientist Jr
    Mar 22, 2006
  3. jobs
    Replies:
    0
    Views:
    1,599
  4. Jc Morin
    Replies:
    1
    Views:
    176
    Jc Morin
    Dec 5, 2003
  5. Earl Teigrob
    Replies:
    1
    Views:
    394
    Shravan
    Mar 1, 2004
Loading...

Share This Page