p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   General .NET (http://p2p.wrox.com/forumdisplay.php?f=122)
-   -   user control / code behind question (http://p2p.wrox.com/showthread.php?t=22179)

whyulil December 6th, 2004 10:14 AM

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?

does
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.

r_ganesh76 December 7th, 2004 12:55 AM

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

Regards
Ganesh

whyulil December 7th, 2004 12:16 PM

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
   ~/admin/what/ever.ascx
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).

planoie January 11th, 2005 11:17 AM

whyulil-

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.


All times are GMT -4. The time now is 12:00 AM.

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