6 Replies - 2260 Views - Last Post: 27 March 2013 - 02:15 PM Rate Topic: -----

#1 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Circular reference

Posted 23 March 2013 - 04:47 AM

*Is it on purpose that the search function at the top right is disabled?*

Now to my problem.

I am getting the message that I my Index.aspx has a circular reference. I have googled a bunch on a solution for this, but got nothing useful.

So the problem arose when I decided to try and learn JQuery's ajax. Therefore I added this to my Index.aspx:
1. <%@ Register Src="Index.aspx" TagPrefix="prefix" TagName="Index" %>
(Is this required when you want to use AJAX in asp.net? And why and when do we use/need the TagPrefix and the TagName?)

2. It started complaining about a Circular reference, so I found out that it was because I was referencing to the same page,
so I created a Dummy called Dummy.aspx, and changed the Register in Index.aspx to:
<%@ Register Src="Dummy.aspx" TagPrefix="prefix" TagName="Index" %>

3. Trying to run now, I got the message: "Dummy does not inherit from System.Web.UI.UserControl".

4. In the Dummy.aspx I added: <%@ Register Src="Index.aspx" TagPrefix="prefix" TagName="Dummy" %>

5. Trying to run it, I again got the message: Dummy.aspx has a circular reference, and I'm stuck here.
I know that the problem is that Dummy.aspx refers to Index.aspx, which refers back to Dummy.aspx, but I just don't
know how to deal with it. Any suggestions?

Thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Circular reference

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,087
  • Joined: 02-July 08

Re: Circular reference

Posted 23 March 2013 - 09:08 AM

@Register is for controls and assemblies. See documention.
Was This Post Helpful? 0
  • +
  • -

#3 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,676
  • Joined: 24-August 11

Re: Circular reference

Posted 26 March 2013 - 08:05 AM

jQuery is a Javascript library, so you add it to your pages like you would references to .js files. If you don't have any experience with jQuery, you should do some research on their site, but based on your download you'll end up with several .js files and possibly several .css files that need to be referenced before the jQuery goodness will work.

This post has been edited by h4nnib4l: 26 March 2013 - 08:07 AM

Was This Post Helpful? 0
  • +
  • -

#4 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: Circular reference

Posted 26 March 2013 - 02:36 PM

View Posth4nnib4l, on 26 March 2013 - 08:05 AM, said:

jQuery is a Javascript library, so you add it to your pages like you would references to .js files. If you don't have any experience with jQuery, you should do some research on their site, but based on your download you'll end up with several .js files and possibly several .css files that need to be referenced before the jQuery goodness will work.

I have much experience with JQuery/Javascript.
But to work with AJAX in asp.net, it seems that the simplest way is to to use the <% @Register %>, but this throws me a circular reference.
Was This Post Helpful? 0
  • +
  • -

#5 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,676
  • Joined: 24-August 11

Re: Circular reference

Posted 27 March 2013 - 07:10 AM

View Post_HAWK_, on 23 March 2013 - 11:08 AM, said:

@Register is for controls and assemblies.


So, for example, if you use the AJAX Controls Toolkit, you add a reference to the .dll in your bin, and then you can use <%@ Register %> on your page to get access (you can also register it all in the web.config, which is my preference for things like this because you get access across the entire project and don't have to repeat yourself on each page you use the tools on). You use the TagPrefix attribute to specify how you start your tags when you use the tools. So, if you say <% ... tagPrefix="ajaxToolkit" ... %>, then when you use the RoundedCornersExtender from the toolkit, your code looks like this: <ajaxToolkit:RoundedCornersExtender runat="server" ... />. You can use a similar technique to register custom controls to use on a page (you can also register them in the web.config for global access).

I can't imagine needing to register a .js file like that. Does the jQuery AJAX come in a separate library file, or is it part of the normal .js files (sorry, I haven't used jQuery in a while, and I've never touched its AJAX components...)?

EDIT: The point that I failed to make is that a register directive needs to be pointing to the resource from which the added functionality is coming. So if you can register jQuery AJAX like that, it would need to be pointing to the .js file, not the .aspx page.

This post has been edited by h4nnib4l: 27 March 2013 - 07:12 AM

Was This Post Helpful? 1
  • +
  • -

#6 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: Circular reference

Posted 27 March 2013 - 11:57 AM

View Posth4nnib4l, on 27 March 2013 - 07:10 AM, said:

View Post_HAWK_, on 23 March 2013 - 11:08 AM, said:

@Register is for controls and assemblies.


So, for example, if you use the AJAX Controls Toolkit, you add a reference to the .dll in your bin, and then you can use <%@ Register %> on your page to get access (you can also register it all in the web.config, which is my preference for things like this because you get access across the entire project and don't have to repeat yourself on each page you use the tools on).


I have tried google for some tutorial on how to register this in the webconfig file, but perhaps I'm using the wrong search keys. Do you happen to know a nice demonstration on this?

This post has been edited by IamTw_: 27 March 2013 - 12:00 PM

Was This Post Helpful? 0
  • +
  • -

#7 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,676
  • Joined: 24-August 11

Re: Circular reference

Posted 27 March 2013 - 02:15 PM

I've never even thought about registering a .js in the web.config; I'm really not sure how that would work, if it would, but I can give you example code from registering an assembly in there.

<compilation debug="true" targetFramework="4.0">
<assemblies>
  <add assembly="AjaxControlToolkit, Version=4.1.50927.0, Culture=Neutral, PublicKeyToken=28f01b0e84b6d53e"/>
</assemblies>  
</compilation>

<pages maintainScrollPositionOnPostBack="true">
<controls>
  <add tagPrefix="ajaxToolkit" 
	   namespace="AjaxControlToolkit" 
	   assembly="AjaxControlToolkit" />
</controls>
</pages>



I'm pretty skeptical about this working, but you're welcome to give it a shot. You might also take a look at this thread on SO.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1