is there some way to make a file (.cs) containing some common C# code
classes being loaded on every .aspx page in my web without me having to
declare it every time?
Something in the config file perhaps?
since I have these classes that will be used on every page, I want them to
be like a "cloud hovering over my web" whatever page the user is browsing... 15 2484
as an example I want to have a code which adds stuff to the <head> control
without having to think about it in my .aspx pages...
Hello David,
not sure I understand your problem...
"classes being loaded(...)with out me having to declare it
every time"
- you could use public "shared" methods in your assembly.
you do not need to instantiate but can simply call them
(stateless).
"as an example I want to have a code which adds stuff to
the <head> control
without having to think about it in my .aspx pages..."
- check this article http://www.devtrain.de/artikel_774.aspx (sorry it`s german
language, but the code examples seem to be understandable -
if not just tell me)
if you really do not want to touch the aspx pages and want
your "dynamic" content...
- maybe check httphandlers or httpmodules (never tried
this on my own...)
msdn section on httphandlers: http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/cpguide/html/cpconhttphandle rs.asp )
msdn-mag article on httpmodules: http://msdn.microsoft.com/msdnmag/is...05/asp/default.
aspx
Hope this helps!
Regards,
Tom -----Original Message----- is there some way to make a file (.cs) containing some
common C# codeclasses being loaded on every .aspx page in my web
without me having todeclare it every time? Something in the config file perhaps?
since I have these classes that will be used on every
page, I want them tobe like a "cloud hovering over my web" whatever page the
user is browsing...
.
I am coding with a text editor (not VS) so I'm not using assemblies...
I think the solution will be to use src="initpages. cs" in the @page
directive and have a Page_Load() event handler in that .cs file that would
append neccesary header tags etc...
currently working on it, if the idea is ridicilous maybe you let me know as
a .Net newbie I easily do stupid things :)
darn I cannot find out how to add attributes to the Page header under
Onload(), this is my current try... anyone please?
using System.Web.UI;
public class Initialiser : Page
{
private void Page_Load(objec t sender, System.EventArg s e)
{
Control.Page.At tributes.Add("n ame", "David");
}
}
Hi David,
what exactly are you trying to achieve?
Do you want to set META-Tags from one specific source
using inline-code (no code behind) ?
If so -
just store your MetaTag Informations as string in an
ApplicationVari able and write them
using "response.write ")...
in global.asax add (application_on Start):
Application.Add ("MetaInformati on", "<META
NAME=""Author"" CONTENT=""David "">")
In your aspx file add (at the place you want the output -
so maybe in the <HEAD> Section...):
<% response.write( application.ite m
("MetaInformati on")) %>
Hope this helps you!
Tom -----Original Message----- darn I cannot find out how to add attributes to the Page
header underOnload(), this is my current try... anyone please?
using System.Web.UI; public class Initialiser : Page { private void Page_Load(objec t sender, System.EventArg s e) { Control.Page.At tributes.Add("n ame", "David"); } }
.
thx Tom, good point but actually I'd like to do it with code behind. I'm
trying to keep code & html as much seperated as possible. There's something
out there I'm not grasping since I can't access the header object from my
code behind, as simple as the code is:
---default.aspx---
<%@ Page Language="C#" Inherits="Initi aliser" Src="initialise r.cs" %>
<head id="MyHeader" runat="server"> </head>
testing testing
---initialiser.cs---
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
public class Initialiser : Page
{
private void Page_Load(objec t sender, System.EventArg s e)
{
MyHeader.Attrib utes.Add("Title ", "dsafadsf") ;
}
}
puh - now i understand what you want ;-)
you are trying to do as described in the link, mentioned
before ( http://www.devtrain.de/artikel_774.aspx )
....
your code (HTML):
<head id="myHeader" runat="server"> </head>
your code (codebehind) :
PageLoad:
Dim myTag As HtmlGenericCont rol = New
HtmlGenericCont rol("meta")
myTag.Attribute s.Add("name", "Author")
myTag.Attribute s.Add("content" , "david")
myHeader.Contro ls.Add(myTag)
## dont forget ##
you have to add:
Protected myHeader As HtmlGenericCont rol
to your page controls declaration....
works as desired? hope so!
;-)
Cheers,
Tom -----Original Message----- thx Tom, good point but actually I'd like to do it with
code behind. I'mtrying to keep code & html as much seperated as possible.
There's somethingout there I'm not grasping since I can't access the
header object from mycode behind, as simple as the code is:
---default.aspx--- <%@ Page Language="C#" Inherits="Initi aliser"
Src="initialise r.cs" %><head id="MyHeader" runat="server"> </head> testing testing
---initialiser.cs--- using System; using System.Data; using System.Web.UI; using System.Web.UI.W ebControls; using System.Web.UI.H tmlControls;
public class Initialiser : Page { private void Page_Load(objec t sender, System.EventArg s e) { MyHeader.Attrib utes.Add("Title ", "dsafadsf") ; } }
.
thx again Tom exactly what I'm trying just in c# :-)
there's something wrong with my c# syntax...
public class Initialiser : Page
{
protected HtmlGenericCont rol myHeader = HtmlGenericCont rol("meta");
private void Page_Load(objec t sender, System.EventArg s e)
{
// myHeader.Contro ls....
}
}
this will be my last, I'm getting hilariosly longposted on this topic!
but it seems the namespace is missing;
namespace.HtmlG enericControl myHeader = HtmlGenericCont rol("meta");
so the final question will be; how can I find the namespace of my aspx
page?? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Albert Wagner |
last post by:
I have just had a problem that I cannot find any reference to in any
docs. Admittedly, I am a JavaScript newbie, but this sure seems like a
bug or an "undocumented feature" in Opera 7.11. I have some debugging
code that writes messages to a TEXTAREA. I named the function that
writes to the TEXTAREA "print", e.g.
content = "";
cnt = 0;
function print(aLine) {
content += (aLine + "\n");
|
by: AES/newspost |
last post by:
I've just re-scanned most of the 60+ posts in the "Frames are Evil"
thread, and my question, as the admittedly and permanently amateur
creator and maintainer of a simple site, is:
Using only elementary HTML and CSS code, how do I create a
simple "framelike" main page without being evil?
where definition of "how" is
--Example of a skeleton HTML template
|
by: farmer |
last post by:
I need "include" multiple classes from multiple files such as:
<%@ Page Language="C#" Debug="true" ValidateRequest="false"
Src="~/Auth/Pub/Auth.cs"%>
<%@ Page Language="C#" Debug="true" ValidateRequest="false"
Src="~/Edit/Item.cs"%>
But the compile says can't use more than one "@Page" directive.
Or,I need to "include" another class from a .cs into a currently .ascx
using:
|
by: NewToCPP |
last post by:
I am having some trouble including "iostream" "fstream" to my code.
I tried the following ways and base times it did not work. What is the
problem?
test.cc:
=======
.....
#include <iostream.h>
#include <fstream.h>
|
by: Alex Maghen |
last post by:
It seems like, the way ASP.NET 2.0 works, I should be able to build a
pre-compiled version of my site so that none of the code of the site would be
accessible by the people for whom I developed it.
If I've built a site in VS 2005 that has lots of ASPX files, a few ASCX
files, both with .CS code-behinds, and a bunch of class files in the APP_CODE
directory, is there a way to "build" the site and obscure it's files and
parts as much as...
| |
by: laredotornado |
last post by:
Hi,
I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed
using Apache's apxs and the php library was installed to
/usr/local/php. However, when I set my "error_reporting" setting to be
"E_ALL", notices are still not getting reported. The perms on my file
are 664, with owner root and group root. The php.ini file is located
at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem
to be having an effect? ...
|
by: deathtospam |
last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using
Visual Studio .NET 2005 -- it worked, I saved it and closed the
project. Today, I came back to the project, reopened the solution, and
was greeted with the following error:
========================================================================
It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error...
|
by: =?Utf-8?B?UGV0ZXI=?= |
last post by:
Hi,
I’m new to aspx and asp.net. We have a huge web based application developed
in ASP. I started working with ASP.net and discovered the strength of this
language. The idea is to start rewriting our asp based application page by
page into asp.net. I rewrote one page in asp.net and the page on itself
works. The start page of the application is an 800 lines long ASP page with
includes. I replaced the <!-- #include file="./119_01.asp"...
|
by: Jeremy J Starcher |
last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even
recommend the use of "window.alert()" over "alert()".
I can't find any technical reason to make this distinction, and seems to
have a (tiny) amount overhead since window itself points to the global
object, hence, a circular reference.
(From everything I am reading, window is just a REFERENCE back to the
global object, as opposed to a separate object.)
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |