Where is Page.RegisterClientScriptBlock Available?

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Jun 10, 2006.

  1. I have used the RegisterClientScriptBlock method in external functions of
    mine (ones that are saved in a separate *.vb file), where I use them as
    follows:

    Public Shared Sub MyFunction(ByVal txtbox As TextBox)
    'other code
    txtbox.Page.RegisterClientScriptBlock("mykey","myscript")
    'other code
    End Sub

    When I use this external function in my *.aspx.vb files, it does what I want
    and expect. However, when I try to use the RegisterClientScriptBlock in my
    *.aspx.vb files, it is not included in the list of methods, properties, etc.
    when I type 'Page.' Why is Visual Basic not listing this method with the
    others while I am writing my code? The *.aspx.vb file inherits
    System.Web.UI.Page just like all the *.aspx.vb files. Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Jun 10, 2006
    #1
    1. Advertising

  2. Nathan Sokalski

    Mark Rae Guest

    "Nathan Sokalski" <> wrote in message
    news:...

    > When I use this external function in my *.aspx.vb files, it does what I
    > want and expect. However, when I try to use the RegisterClientScriptBlock
    > in my *.aspx.vb files, it is not included in the list of methods,
    > properties, etc. when I type 'Page.'


    Is it available when you type 'Me.'?
    Mark Rae, Jun 10, 2006
    #2
    1. Advertising

  3. You need a reference to the actual Page object for the page that is
    created as a response to the request.

    In the example you show, that is accomplished by the fact that the
    control that you are passing to the method contains a reference to the
    page that it has been added to.

    Inheriting the Page class would give you access to the
    RegisterClientScriptBlock method, but that doesn't help you a bit. You
    need a reference to the page that is being created, not just any Page
    object.

    Nathan Sokalski wrote:
    > I have used the RegisterClientScriptBlock method in external functions of
    > mine (ones that are saved in a separate *.vb file), where I use them as
    > follows:
    >
    > Public Shared Sub MyFunction(ByVal txtbox As TextBox)
    > 'other code
    > txtbox.Page.RegisterClientScriptBlock("mykey","myscript")
    > 'other code
    > End Sub
    >
    > When I use this external function in my *.aspx.vb files, it does what I want
    > and expect. However, when I try to use the RegisterClientScriptBlock in my
    > *.aspx.vb files, it is not included in the list of methods, properties, etc.
    > when I type 'Page.' Why is Visual Basic not listing this method with the
    > others while I am writing my code? The *.aspx.vb file inherits
    > System.Web.UI.Page just like all the *.aspx.vb files. Thanks.
    Göran Andersson, Jun 10, 2006
    #3
  4. No, it is not.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Mark Rae" <> wrote in message
    news:...
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >
    >> When I use this external function in my *.aspx.vb files, it does what I
    >> want and expect. However, when I try to use the RegisterClientScriptBlock
    >> in my *.aspx.vb files, it is not included in the list of methods,
    >> properties, etc. when I type 'Page.'

    >
    > Is it available when you type 'Me.'?
    >
    Nathan Sokalski, Jun 11, 2006
    #4
  5. I realize that I need access to the Page object that is being created, but
    shouldn't the keyword Me do that, as Mark Rae mentioned in one of the other
    responses?
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Göran Andersson" <> wrote in message
    news:%...
    > You need a reference to the actual Page object for the page that is
    > created as a response to the request.
    >
    > In the example you show, that is accomplished by the fact that the control
    > that you are passing to the method contains a reference to the page that
    > it has been added to.
    >
    > Inheriting the Page class would give you access to the
    > RegisterClientScriptBlock method, but that doesn't help you a bit. You
    > need a reference to the page that is being created, not just any Page
    > object.
    >
    > Nathan Sokalski wrote:
    >> I have used the RegisterClientScriptBlock method in external functions of
    >> mine (ones that are saved in a separate *.vb file), where I use them as
    >> follows:
    >>
    >> Public Shared Sub MyFunction(ByVal txtbox As TextBox)
    >> 'other code
    >> txtbox.Page.RegisterClientScriptBlock("mykey","myscript")
    >> 'other code
    >> End Sub
    >>
    >> When I use this external function in my *.aspx.vb files, it does what I
    >> want and expect. However, when I try to use the RegisterClientScriptBlock
    >> in my *.aspx.vb files, it is not included in the list of methods,
    >> properties, etc. when I type 'Page.' Why is Visual Basic not listing this
    >> method with the others while I am writing my code? The *.aspx.vb file
    >> inherits System.Web.UI.Page just like all the *.aspx.vb files. Thanks.
    Nathan Sokalski, Jun 11, 2006
    #5
  6. Nathan Sokalski

    Teemu Keiski Guest

    in VS, check

    Tools->Options->Text Editor->Basic->General

    and check that "Hide advanced members" is unchecked. If it is checked, VS
    will hide some methods from you.


    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    "Nathan Sokalski" <> wrote in message
    news:...
    > No, it is not.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "Mark Rae" <> wrote in message
    > news:...
    >> "Nathan Sokalski" <> wrote in message
    >> news:...
    >>
    >>> When I use this external function in my *.aspx.vb files, it does what I
    >>> want and expect. However, when I try to use the
    >>> RegisterClientScriptBlock in my *.aspx.vb files, it is not included in
    >>> the list of methods, properties, etc. when I type 'Page.'

    >>
    >> Is it available when you type 'Me.'?
    >>

    >
    >
    Teemu Keiski, Jun 12, 2006
    #6
  7. THANK YOU! It might have taken me who knows how long to find that, and it is
    definitely an important method in some cases. Thanks again!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Teemu Keiski" <> wrote in message
    news:...
    > in VS, check
    >
    > Tools->Options->Text Editor->Basic->General
    >
    > and check that "Hide advanced members" is unchecked. If it is checked, VS
    > will hide some methods from you.
    >
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >> No, it is not.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>
    >> "Mark Rae" <> wrote in message
    >> news:...
    >>> "Nathan Sokalski" <> wrote in message
    >>> news:...
    >>>
    >>>> When I use this external function in my *.aspx.vb files, it does what I
    >>>> want and expect. However, when I try to use the
    >>>> RegisterClientScriptBlock in my *.aspx.vb files, it is not included in
    >>>> the list of methods, properties, etc. when I type 'Page.'
    >>>
    >>> Is it available when you type 'Me.'?
    >>>

    >>
    >>

    >
    >
    Nathan Sokalski, Jun 12, 2006
    #7
  8. Only if the code is inside the page class. If the code is in some other
    class, the Me keyword references the instance of that class.

    Nathan Sokalski wrote:
    > I realize that I need access to the Page object that is being created, but
    > shouldn't the keyword Me do that, as Mark Rae mentioned in one of the other
    > responses?
    Göran Andersson, Jun 12, 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. John Livermore
    Replies:
    1
    Views:
    526
    Teemu Keiski
    Jul 25, 2003
  2. Natty Gur
    Replies:
    0
    Views:
    2,569
    Natty Gur
    Jun 6, 2004
  3. =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?=
    Replies:
    0
    Views:
    2,382
    =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?=
    Jun 7, 2004
  4. Nathan Sokalski
    Replies:
    9
    Views:
    2,643
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jun 12, 2006
  5. Nathan Sokalski

    Where is Page.RegisterClientScriptBlock Available?

    Nathan Sokalski, Jun 10, 2006, in forum: ASP .Net Building Controls
    Replies:
    7
    Views:
    117
    Göran Andersson
    Jun 12, 2006
Loading...

Share This Page