ASPX vs. ASCX

Noob Question of the Day

Page 1 of 1

6 Replies - 28483 Views - Last Post: 04 September 2007 - 04:10 PM Rate Topic: -----

#1 techknow  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 67
  • Joined: 29-August 07

ASPX vs. ASCX

Post icon  Posted 02 September 2007 - 12:01 PM

What is reason to use a aspx (.net page) extension vs a ascx (.net control) extention?

I have installed a new forum (yetanotherforum.net which I recommend highly) that I would like to start tweaking. Most of the pages are ascx, I am thinking that they use this extension becuase they are part of another page?

Anyway, my noob contibution for the day...

Oh, yeah

Do they need to be compiled if I make changes?

Is This A Good Question/Topic? 0
  • +

Replies To: ASPX vs. ASCX

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ASPX vs. ASCX

Posted 02 September 2007 - 12:06 PM

The .aspx is the actual page, what the user views in their browser, the .ascx is a custom user control that is used in the .aspx page. You cannot display a .ascx file in a web browser, just the .aspx page.

If making changes then yes they have to be re-compiled to reflect the changes (and have to be re-uploaded to your host if you're developing locally and hosting elsewhere).

Hope this helps :)
Was This Post Helpful? 1
  • +
  • -

#3 techknow  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 67
  • Joined: 29-August 07

Re: ASPX vs. ASCX

Posted 04 September 2007 - 10:25 AM

Indeed it does. Is there a compelling reason to wire up a ascx page, other then to seperate code from content?

I am not certain why I wouldn't simply use the aspx.vb code behind page.
Was This Post Helpful? 1

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ASPX vs. ASCX

Posted 04 September 2007 - 10:44 AM

User controls are handy, lets say you need a certain functionality on more than one page, you create a user control that incorporates that functionality then drag it onto your page and voila, no need to rewrite the same code for multiple pages.
Was This Post Helpful? 0
  • +
  • -

#5 techknow  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 67
  • Joined: 29-August 07

Re: ASPX vs. ASCX

Posted 04 September 2007 - 01:33 PM

Ok, fair enough, but I am still unclear regarding the difference/advantages of using the ascx over the aspx.vb

It appears to me that either format acheives the same goal. Is this the case?

I would like to say, thanks. This community has been very helpful. I look forward to reaching a competency in which I can make some meaningful contributions.

At this point however, I will have to be satisfied offering questions that will hopefully help others as well as me.
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ASPX vs. ASCX

Posted 04 September 2007 - 03:08 PM

The major advantage is not having to write the same code multiple times for the same functionality, also in your code behind its cleaner as you don't have many many lines of come for a single piece of functionality. If at all possible, when you need identical functionality on more than one page, create a user control.

Also, with user controls you can override functionality of a control to add your own, I have written many controls where you override the OnPaint event and such to add the functionality you want for that specific control
Was This Post Helpful? 1

#7 techknow  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 67
  • Joined: 29-August 07

Re: ASPX vs. ASCX

Posted 04 September 2007 - 04:10 PM

I see. Makes alot of sense, and beats redundant code.

This is new with 2.0 correct?

Also, can you not write a control in the aspx.vb page?

Lastly, can you also share code in the aspx.vb between pages?

b.t.w. Thanks for the SQL Tutorial I will be pouring over that in the weeks to come.
Was This Post Helpful? 1

Page 1 of 1