Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Src Problem for User Controls in SubDirectories

  Asked By: Francisca    Date: Jun 30    Category: Asp.net    Views: 1183
  

I've created a user control that I need to add to a variety of different aspx
pages. One of the aspx pages sits in the main directory, the other sits in a
sub-directory. When I try to open the aspx page within the subdirectory - I get
a src error when my page references my user controls. How do I fix this? Does
all the usercontrols I'm using have to be copied into the subdirectory as well?
That doesn't seem like an efficient solution since changes to the user control
will have to be made in both the main and sub directories.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Isabella Campbell     Answered On: Jun 30

In your "Register" server statement correct the scr element:
<%@ Register TagPrefix="userControl" TagName="NameOfTheControl"
src="subdirectory/usercontrol.ascx" %>
it should work wahtever the folder...

if you have to go up one folder start with ../subdirectory/usercontrol.ascx

Maybe your usercontrol uses some elements with src (like IMG). For use like this
it's best to make a public string property like imageFolder, to link to the
right folder. user  controls (when linked to an aspx  file) search for such
elements as if they would me in the folder of the ASPX file. Not as they would
be in the folder of the ASCX.

 
Didn't find what you were looking for? Find more on Src Problem for User Controls in SubDirectories Or get search suggestion and latest updates.




Tagged: