Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Can someone help me stop repeating code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vince - 06 Sep 2007 02:13 GMT
I have this code that appears at the top of every page

I have tried putting this into my master page, however, the error
message doesnt appear when I do this even though I have the variables
declared in the other pages.

<asp:Content id="contentErrors" ContentPlaceHolderID="siteErrors"
runat="server">
 <% if (pageErrors) { %>
 <div class="siteError">
   <h2>Error</h2><em><%=pageError %></em>
 </div>
 <% } %>
</asp:Content>

I could use an iframe and link a error.aspx page within it and pass
the values as parameters via the URL, but this seems cumbersome to me.

Any suggestions?
Showjumper - 06 Sep 2007 02:40 GMT
You can set a custom error page in web.config. Is that what you need? Also
you can use Server.GetLastError to get the error message.
>I have this code that appears at the top of every page
>
[quoted text clipped - 15 lines]
>
> Any suggestions?
Vince - 06 Sep 2007 02:58 GMT
> You can set a custom error page in web.config. Is that what you need? Also
>
[quoted text clipped - 17 lines]
>
> > Any suggestions?

Well thats a whole error page, im just looking at a div that appears
at the top of every page and is only displayed when needed.

Ill have a look at GetLastError. Cheers.
Vince - 07 Sep 2007 02:02 GMT
> > You can set a custom error page in web.config. Is that what you need? Also
> > you can use Server.GetLastError to get the error message."Vince" <panuccio.vi...@gmail.com> wrote in message
[quoted text clipped - 25 lines]
>
> Ill have a look at GetLastError. Cheers.

Actually I checkd GetLastError. This seems more to do with application
level errors. Im after something for user errors such as missing data
entry or wrong formatted date.

Anyone?
Juan T. Llibre - 07 Sep 2007 03:16 GMT
re:
!> Im after something for user errors such as missing data entry or wrong formatted date.

For that, use structured error exception handling.

( Try, Catch, Finally )

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================

>> > You can set a custom error page in web.config. Is that what you need? Also
>> > you can use Server.GetLastError to get the error message."Vince" <panuccio.vi...@gmail.com> wrote in message
[quoted text clipped - 31 lines]
>
> Anyone?
Larry Bud - 07 Sep 2007 13:05 GMT
> I have this code that appears at the top of every page
>
[quoted text clipped - 15 lines]
>
> Any suggestions?

What about in a user control?
Ghostman - 07 Sep 2007 16:16 GMT
Sorry for the Hijack..

speaking of Error Handling.  I have set it up at the Application level
a few times using global.asax, but is there a way to set up a default
global.asax file that i can have multiple asp.net applications point
to?
ThunderMusic - 07 Sep 2007 18:48 GMT
Hi,
I think it's a "BasePage" case...  If you make all your pages inherit from a
"BasePage" class (that inherits from Page), you can put everything you want
"global" in this "BasePage" without needing every single page to declare for
example the 'pageErrors' variable.

I hope it helps

ThunderMusic

>I have this code that appears at the top of every page
>
[quoted text clipped - 15 lines]
>
> Any suggestions?
ThunderMusic - 07 Sep 2007 18:51 GMT
hi
btw, I also agree with Larry Bud's post saying you could use a user control,
but you would still need to copy-paste the usercontrol to every single
page...  coupled with the "BasePage", it could be terrific... ;)

I hope it helps

ThunderMusic

> Hi,
> I think it's a "BasePage" case...  If you make all your pages inherit from
[quoted text clipped - 25 lines]
>>
>> Any suggestions?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.