|
-
Mar 31st, 2007, 12:39 AM
#1
Thread Starter
Fanatic Member
[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") "
-
Apr 7th, 2007, 12:52 PM
#2
Thread Starter
Fanatic Member
Re: [02/03] properties and methods of usecontrol
anyone trying
same thing works in vs 2005 and not in vs 2003
-
Apr 7th, 2007, 01:01 PM
#3
Lively Member
Re: [02/03] properties and methods of usecontrol
your question is not very clear be precised
-
Apr 7th, 2007, 01:49 PM
#4
Thread Starter
Fanatic Member
Re: [02/03] properties and methods of usecontrol
 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 ?
-
Apr 8th, 2007, 04:10 AM
#5
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"
?
-
Apr 8th, 2007, 09:02 AM
#6
Thread Starter
Fanatic Member
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.
-
Apr 10th, 2007, 04:17 PM
#7
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?
-
Apr 11th, 2007, 01:43 AM
#8
Thread Starter
Fanatic Member
Re: [RESOLVED] [02/03] properties and methods of usecontrol
 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.
-
Apr 11th, 2007, 03:06 AM
#9
Thread Starter
Fanatic Member
Re: [RESOLVED] [02/03] properties and methods of usecontrol
 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
-
Apr 11th, 2007, 09:35 AM
#10
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.
-
Apr 12th, 2007, 04:55 AM
#11
Thread Starter
Fanatic Member
Re: [RESOLVED] [02/03] properties and methods of usecontrol
 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
-
Apr 12th, 2007, 07:47 AM
#12
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|