Results 1 to 12 of 12

Thread: [RESOLVED] [02/03] properties and methods of usecontrol

  1. #1

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Resolved [RESOLVED] [02/03] properties and methods of usecontrol

    this post should read by those who have used vs 2003.

    i have a simple usercontrol with a public sub

    Code:
       Public sub Setstr() 
            Response.Write("test message")   
      End sub

    this usercontrol loads in the comsumer form.

    on the button click in consumer form , i make a call to the public procedure

    Code:
     WebUserControl11.Setstr()
    error i get
    Object reference not set to an instance of an object .
    highlighting "Response.Write("test message") "
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  2. #2

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Re: [02/03] properties and methods of usecontrol

    anyone trying

    same thing works in vs 2005 and not in vs 2003
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  3. #3
    Lively Member
    Join Date
    Aug 2006
    Location
    india
    Posts
    88

    Re: [02/03] properties and methods of usecontrol

    your question is not very clear be precised

  4. #4

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Re: [02/03] properties and methods of usecontrol

    Quote Originally Posted by neeshu30
    your question is not very clear be precised
    i have a web user control with a public procedure .

    can i call the public procedure from the parent form ?
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] properties and methods of usecontrol

    Theoretically, you should be able to call the method from your page.

    What happens when you replace

    Response.Write("test message")

    with

    Dim x As String = "test"

    ?

  6. #6

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Re: [02/03] properties and methods of usecontrol

    in vs 2003 , when a usercontrol is placed on a web page , we do not get a object instance in code behind file ( .aspx.vb )

    it has to be created.

    so i did one .

    which is like this :

    dim WithEvents WebUserControl11 As WebUserControl1

    as i am working on a usercontrol for the first time , it didn't struck my mind
    it should be protected instead of dim .

    so now its working.

    i know the basic difference between the two as far as inheritance is concerned , but i don't know how that is affecting my case here ?
    Last edited by vishalmarya; Apr 9th, 2007 at 03:23 AM.
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [02/03] properties and methods of usecontrol

    Ah, I had assumed it was created for you. Visual Studio does create it, but there's an intermittent bug in which the control is not declare in the codebehind. My observation is that if you place the control on the page in design view, you have to save it first, and then go to the codebehind.

    I don't know what you mean by "affecting my case here." Affecting what?

  8. #8

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Re: [RESOLVED] [02/03] properties and methods of usecontrol

    Quote Originally Posted by mendhak
    I don't know what you mean by "affecting my case here." Affecting what?
    i started new thread for that

    http://www.vbforums.com/showthread.php?t=462242
    Last edited by vishalmarya; Apr 11th, 2007 at 03:06 AM.
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  9. #9

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Re: [RESOLVED] [02/03] properties and methods of usecontrol

    Quote Originally Posted by mendhak
    Ah, I had assumed it was created for you. Visual Studio does create it, but there's an intermittent bug in which the control is not declare in the codebehind. My observation is that if you place the control on the page in design view, you have to save it first, and then go to the codebehind.
    after placing the control , i saved the page , build , rebuild , closed and opened it again , still did not got the object in code behind.

    i am using .net 1.1 sp1 , vs 2003 sp1
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [02/03] properties and methods of usecontrol

    You're stuck with that then, it's one of the various bugs that were never resolved, AFAIK, with VS 2003. Only a workaround that worked for some.

  11. #11

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Re: [RESOLVED] [02/03] properties and methods of usecontrol

    Quote Originally Posted by mendhak
    You're stuck with that then, it's one of the various bugs that were never resolved, AFAIK, with VS 2003. Only a workaround that worked for some.
    i don't think it is a bug.
    it is supposed be like that only.

    a msdn atricle , march 2004 , clearly states that u have to explicitly declare a variable for the usercontrol to use in the code behind.

    search for :

    "Create a protected member variable in the Web page's code-behind"

    in

    http://msdn2.microsoft.com/en-us/library/ms972975.aspx
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [02/03] properties and methods of usecontrol

    I was at a Microsoft conference where I spoke to the ASP.NET product manager about this. I am telling you what he told me and his acknowledgment that it is one of those magical features.

    Second, it has worked for me in the past while I have not been hallucinating. Additionally, it has worked for others. Therefore, there is a disconnect here. It does not work for you, though, but I have no explanation for it.

    Third, that is by Scott Mitchell, so it cannot represent Microsoft's own opinion about the matter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width