Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 6th, 2004, 10:14 AM
Authorized User
Join Date: Jun 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default user control / code behind question

Hi everybody, its been a few months since iv done anything with .net and i have a few questions.

Does the .vb file for a user control have to be compiled before it can be used?

if indexof("src=") = -1 then....
mean the same as
if instr("src=") = false then....
(i know the syntax is wrong but you get it, hopefully)

is there a way of stopping .net from changing the id of elements to ctl_blahblahblahIdOfElement, its real annoying.
Old December 7th, 2004, 12:55 AM
Friend of Wrox
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76

Your first question:
  You need to compile the code behind file of the user control inorder to use the same (.ascx file) in a different web application

Old December 7th, 2004, 12:16 PM
Authorized User
Join Date: Jun 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts

Well im using dotnetnuke, and i have created a skin for it.
there are a bunch of User Controls(UC) at the top and im fiddling with 1 of them.
All the UC have the source pointing to
and i have changed the one i want to edit to links.ascx and ive copied the relevant files (links.ascx AND links.ascx.vb) to the same folder as the skin.ascx.

I have changed the vb file quite a bit but none of the changes appear to have any affect. (ive altered something to put <li> instead of <span> and i have checked the source of the output).
Old January 11th, 2005, 11:17 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts


You do not have to compile to use codebehind, although this is how most people do it. In the page or control tag, there is a "src" attribute where you can specify the class source. This is NOT the same as the "CodeBehind" attribute that is used by visual studio to link up the page/control with the code-behind file.

<%@ Page src="myPage.aspx.vb" inherits="myNamespace.myPage" %>
<%@ Control src="myControl.ascx.vb" inherits="myNamespace.myControl" %>

Regarding the control names: are you referring to the resulting control names in the page HTML output? You cannot do anything about this. .NET has to have a way to differentiate between different controls on the page. If you don't provide an explicit name for a control .NET will name it for you (ctl0, ctl1...). If you need to use these controls in client-side script, you should learn about the 'ClientID' attribute that all controls have. This will give you the complete control ID on the client side so that you can make references to it without any hardcoding (and breaking) of client side names. Post again if you want more detail on this.

Similar Threads
Thread Thread Starter Forum Replies Last Post
user control code chroniclemaster1 ASP.NET 2.0 Professional 11 September 25th, 2008 03:53 PM
User control question scott_rider ASP.NET 1.x and 2.0 Application Design 6 May 20th, 2008 03:59 PM
Loading user control dynamically from code-behind jacob ASP.NET 1.0 and 1.1 Basics 2 April 12th, 2004 06:06 PM
User Control / Code-behind ViagraFalls ASP.NET 1.0 and 1.1 Basics 3 November 1st, 2003 09:18 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.