CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting
ASP.NET MVC Ready – 3 Months Free and Free Setup



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 1/11/2004 12:39:12 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 33 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
Thomas1
Asp.Net User
Custom control- problem with having it twice on an .aspx page1/11/2004 12:39:12 AM

0/0

Hey everyone; I wrote up a custom control that inherited from a textbox, with a public method. It worked great in a test .aspx page, so I added a second instance right below the first. What's strange is that I can only call the first object's method. Even Intellisense will display the method name. But when I try to call the second object's method, I don't get any Intellisense help, and I get the error message "\\testcontrol.aspx.cs(64): The type or namespace name 'TomsTextBox2' could not be found (are you missing a using directive or an assembly reference?)" What am I missing?

At the top of the testcontrol.aspx file, I have this in the HTML:


<%@ Register TagPrefix="TomsControls" Namespace="testcustomcontrols" Assembly="testcustomcontrols" %>


Then I added the controls to the page, one after the other, like this:


<TomsControls:FunnyTextBox id="FunnyTextBox1" runat="server" FunnyColor="blue"></TomsControls:FunnyTextBox>
<TomsControls:FunnyTextBox id="FunnyTextBox2" runat="server" FunnyColor="blue"></TomsControls:FunnyTextBox>


Finally, I tried to do this in the codebehind:


private void btnSubmit_Click(object sender, System.EventArgs e)
{
FunnyTextBox1.FlipColor();
FunnyTextBox2.FlipColor();
}


When I type "FunnyTextBox1.", Intellisense shows me the FlipColor() method. When I type "FunnyTextBox2.", I don't get anything. If I finish the line so it reads "FunnyTextBox2.FlipColor()", and try to build the solution, I get the error mentioned in my first paragraph above.

Here's the strange part! By random flipping back and forth between the code-behind .aspx.cs file, and the .asp's html view, I tried changing the id of the second control to "FunnyTextBox3" inside the HTML.

I went back to the .aspx.cs code-behind, and I still couldn't access FunnyTextBox3.whatever. No intellisense, and I still get an error when I try to build the solution.

I went back to the .asp page, in design view, and changed the second control's id back to FunnyTextBox2. I clicked on the HTML view, and yes, the property of the control shows that the id -is- FunnyTextBox2. So I went back to the code behind file.

When I type "this.", Intellisense now shows me "FunnyTextBox1", "FunnyTextBox2", AND "FunnyTextBox3"!! What the HECK is going on here? If I rebuild the solution, all three still exist. If I try referencing funnytextbox3.flipcolor(), it builds okay- and of course, it fails when the project runs.

What happens to Visual Studio .NET 2003 when I flip between "Design" and "HTML" view of an .aspx file?? Am I supposed to recompile that file only? Is this a bug in the IDE?

I've even tried exiting VS.NET, exiting VS.NET and logging out and logging back in, and exiting VS.NET and rebooting- same thing. The second control ID is always erratic. Any and all help would be appreciated!

Thanks!!

-Thomas
Thomas1
Asp.Net User
Re: Custom control- problem with having it twice on an .aspx page1/11/2004 12:56:35 AM

0/0

Oops! I have an error in my above post. The error message is really "\testcontrol.aspx.cs(64): The type or namespace name 'FunnyTextBox2' could not be found (are you missing a using directive or an assembly reference?)" As you can tell, I keep changing the name of my custom control :)

I should add, too, that the name of the solution is "testcustomcontrols", the namespace is "testcustomcontrols", and the custom control was also written using "testcustomcontrols" as the namespace. So I'm not, as the error message suggests, missing a using directive or an assembly reference, because the code-behind of testcontrol.aspx.cs is written in the testcustomcontrols namespace! (Saying "using testcustomcontrols" twice would be redundant, right?)

Thanks!

-Thomas
Thomas1
Asp.Net User
Re: Custom control- problem with having it twice on an .aspx page1/12/2004 1:55:46 AM

0/0

Ah- I think I nailed it. Never thought to look "up" in the code behind.

At the top, there's


protected System.Web.UI.WebControls.TextBox txtNormalBox;
protected System.Web.UI.WebControls.Button btnSubmit;
protected testcustomcontrols.FunnyTextBox FunnyTextBox1;
protected testcustomcontrols.FunnyTextBox FunnyTextBox3;
protected testcustomcontrols.FunnyTextBox FunnyTextBox2;


What's funny about this is that it seems, for the second control I place in the HTML code, the VS.NET 2003 IDE is "slow" to either (A) put a reference into the code-behind or (B) remove a reference or (C) change the reference. I don't even have a FunnyTextBox3 or FunnyTextBox2 on the .aspx page anymore!

Further testing- In order to get the reference to appear correctly "automatically", it seems the procedure has to be:

1. Type in the code, in the .aspx's HTML view, to put your custom control on the screen.
2. Click on the "Design" view tab of the .aspx file
3. Now go to the code-behind. The reference is correct.

If you go right from putting the custom control into the HTML view, to the code-behind, you don't get the reference added automatically.

If you put the custom control into HTML view, and save "all files", and go to the code-behind file, the reference is still NOT put into the code-behind automatically.

If you put the custom control into HTML view, save "all files", and do a debug/start, the reference is still NOT put into the code-behind automatically!

The only way for it to appear is to switch to design mode of the .aspx file, and then go to the code-behind. I think I'll send Microsoft an e-mail about this.

Hope this helps someone out!


-Thomas
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 2.0 Databases: Beta Preview Authors: John Kauffman, Thiru Thangarathinam, Pages: 404, Published: 2005
Real World SharePoint 2007: Indispensable Experiences from 16 MOSS and WSS MVPs Authors: Scot Hillier, Robert Bogue, Adam Buenz, Andrew Connell, Stacy Draper, Luis Du Solier Grinda, Todd O. Klindt, Jason Medero, Dustin Miller, Shane Perran, Joris Poelmans, Heather Solomon, Nick Swan, Jan Tielens, Mike Walsh, Shane Young, Pages: 478, Published: 2007
Fixing PowerPoint Annoyances: How to Fix the Most Annoying Things about Your Favorite Presentation Program Authors: Echo Swinford, Pages: 305, Published: 2006
Microsoft Exchange Server 2003: 24 Seven Authors: Jim McBee, Barry Gerber, Pages: 928, Published: 2004
Beginning ASP.NET 1.1 Databases: From Novice to Professional Authors: Damien Foggon, Daniel Maharry, Pages: 600, Published: 2004
Microsoft Operations Manager 2005 Field Guide Authors: Andy Dominey, Garry Meaburn, Pages: 280, Published: 2006

Web:
custom validator called twice for a control - ASP.NET Forums but when the input-control custom validator gets called twice, then asks the user "You ... and i just have no idea where to look for the problem. ... Like in the code page whith 'Handles' and in the aspx page with 'on. ... I had tried that initially (having the same validator attached to 2 controls) ...
ASP.NET Controls: HierarGrid - A hierarchical DataGrid that ... I have created a custom control called HierarGrid that derives from the DataGrid and a ... Bugfix: corrected problem with non-unique IDs that were generated for ... Bugfix: Exception when calling DataBind twice within one Request ... if the row order or the page index changes between postbacks a wrong row may be ...
CodeProject: ModalDialogHelper Control in ASP.NET 1.1 and 2.0 ... ... popup control for web page wrapped in ASP.NET custom control. SqlWhereBuilder ASP.NET Server Control ... Problem, the page render twice and always get the error form1. ... ajax script manager and update panel on .aspx page. ...
problem with hidden field from a custom control in a form I have a custom control that draws many thing on the screen including a hidden field. ... What I want to do is the following : When there is a postback of the page, I ... cases you may end up drawing controls twice. ...
Web Q&A: Page Ready State, DataGrid Row Deletion, and More The problem can be reproduced by replacing main1.htm with an ASPX page that has a .... Other controls include: GridView (the successor to DataGrid), DataList, .... to keep users from having to log in twice based on the app used in the portal. ... NET session (and session cookie) or do I need to create a new custom ...
Problem handling DataGrid TemplateColumn Databinding Event - ASP ... DatabBinding of the custom control to the, in this case, aspx code-behind (web Page - which has already added an EventHandler for the Shared event). ... First postBack aspx EventHandler handles the raised event twice ...
Why are children of my custom user-control not being initialized ... The OuterControl is used on my Default.aspx page like this: ... When I try to set their values using the ASPX markup, the constructor for the InnerControl is being called twice. ... VB.NET Custom Control (custom drawing) Refresh Problem ...
SingingEels : Dynamically Created Controls in ASP.NET Jun 19, 2007 ... Controls.Add(textBox); } }. (See: Scenario 1/Default_02.aspx) ... You can add plug-in modules, custom fields or change parts of the page .... Controls in the CreateButtons shows that the problem is a little deeper. ... So, why is it necessary to create controls twice when the page layout changes? ...
timer control in a custom control - ASP.NET Forums Hello everyone, I have a problem w/ the timer control. It works fine in a normal aspx page, but when I use it in a custom control, ...
Overriding ClientID and UniqueID on ASP.NET controls - Rick ... Since this control is likely to be only dropped once maybe twice (once for panel ... The Page normally uses the ClientID (the one posted by the client) to find the .... I am facing strange problem.... i have custom control on my aspx ...












creating login database on server

firewall settings for webapplication

authentication problem. please someone help me. thank you.

help! requesting best practices discussion regarding complex security scenario

continued authorization problems

problem with sqltableprofileprovider

how to sign out authorization automatically when browser is closed.

need information about member authentication

running asp.net 2.0 on a windows 2003 (sp1) domain controller

where to catch httprequestvalidationexception exceptions

findcontrol in createuserwizard problems

persistent cookie not persisting

detect cookie expiration?

web scheduler, security.

unknown username or bad password (active directory)

encryp and decrypt data with openssl sertificates?

looking for ideas on how to create a secure rss feed

server error in '/' application.

how can i force a user to logout?

cant access the server file system

authentication question

forms authentication problem with iis

update aspnet_membership table

active directory

problem with cookies

custom membership provider, encrypt password

programatically securing file from browsing

cryptographic service provider (csp) could not be found for this algorithm.

password policy

custom profile object throws exception outside web application

  Privacy | Contact Us
All Times Are GMT