473,804 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting Doctype from codebehind ?

WT
Hello,

I am searching for a way to generate automatically from codebehind the
<!Doctype....fo r asp.net pages using .net 3.5 c# and vs2008.
Subidiary question: if I do a server transfert in my codebehind, do I need
any Doctype or html tags in the page ?

Thanks
CS

Jun 27 '08 #1
6 7947
On May 16, 12:57*pm, "WT" <W...@newsgroup s.nospamwrote:
Hello,

I am searching for a way to generate automatically from codebehind the
<!Doctype....fo r asp.net pages using .net 3.5 c# and vs2008.
Subidiary question: if I do a server transfert in my codebehind, do I need
any Doctype or html tags in the page ?

Thanks
CS
You can override the Render method to put new Doctype to the output

Here's an example
http://www.asp-php.net/scripts/asp.n...tml.php?page=2
Jun 27 '08 #2
Hi CS,

As for the DocType, a simple way to set it via codebehind is declare an
ASP.NET LIteral control in aspx template so that you can assign the doc
type string via Literal control's Text property e.g.
=========aspx== =============
<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="_Defa ult" %>
<asp:literal runat="server" id="dt"></asp:literal>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

==============c ode behind=========

protected void Page_Load(objec t sender, EventArgs e)
{
this.dt.Text= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d\">";

}
=============== =======

Alexey also provided an article which mentioned overriding pages' render
method to write the doctype(or any other output content).

For the subidiary question " if I do a server transfert in my codebehind,
do I need any Doctype or html tags in the page ?", I'm not very sure what
is the exact things you want to do, would you provide some further
description on this? Are you performing some server-side redirection like
Server.Transfer ?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: "WT" <WT@newsgroups. nospam>
Subject: Setting Doctype from codebehind ?
Date: Fri, 16 May 2008 12:57:02 +0200
>
Hello,

I am searching for a way to generate automatically from codebehind the
<!Doctype....f or asp.net pages using .net 3.5 c# and vs2008.
Subidiary question: if I do a server transfert in my codebehind, do I need
any Doctype or html tags in the page ?

Thanks
CS

Jun 27 '08 #3
WT
Hi Steven,

Thanks, your solution seems good.
Do you know a way to detect in codebehind if DocType is set or not in the
current aspx ?

For subs question, Yes I am doing a Server.Transfer from a std Default.aspx
to a std aspx page.

Thanks again.
CS

"Steven Cheng [MSFT]" <st*****@online .microsoft.coma écrit dans le message
de news:6b******** ********@TK2MSF TNGHUB02.phx.gb l...
Hi CS,

As for the DocType, a simple way to set it via codebehind is declare an
ASP.NET LIteral control in aspx template so that you can assign the doc
type string via Literal control's Text property e.g.
=========aspx== =============
<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="_Defa ult" %>
<asp:literal runat="server" id="dt"></asp:literal>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

==============c ode behind=========

protected void Page_Load(objec t sender, EventArgs e)
{
this.dt.Text= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d\">";

}
=============== =======

Alexey also provided an article which mentioned overriding pages' render
method to write the doctype(or any other output content).

For the subidiary question " if I do a server transfert in my codebehind,
do I need any Doctype or html tags in the page ?", I'm not very sure what
is the exact things you want to do, would you provide some further
description on this? Are you performing some server-side redirection like
Server.Transfer ?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>>From: "WT" <WT@newsgroups. nospam>
Subject: Setting Doctype from codebehind ?
Date: Fri, 16 May 2008 12:57:02 +0200
>>
Hello,

I am searching for a way to generate automatically from codebehind the
<!Doctype.... for asp.net pages using .net 3.5 c# and vs2008.
Subidiary question: if I do a server transfert in my codebehind, do I need
any Doctype or html tags in the page ?

Thanks
CS

Jun 27 '08 #4
WT
Thanks Alexey,

And do yo know a way to detect id Doctype is missing or not before the
Render Method ?
CS

"Alexey Smirnov" <al************ @gmail.coma écrit dans le message de
news:71******** *************** ***********@m73 g2000hsh.google groups.com...
On May 16, 12:57 pm, "WT" <W...@newsgroup s.nospamwrote:
Hello,

I am searching for a way to generate automatically from codebehind the
<!Doctype....fo r asp.net pages using .net 3.5 c# and vs2008.
Subidiary question: if I do a server transfert in my codebehind, do I need
any Doctype or html tags in the page ?

Thanks
CS
You can override the Render method to put new Doctype to the output

Here's an example
http://www.asp-php.net/scripts/asp.n...tml.php?page=2

Jun 27 '08 #5
Thanks for your reply CS,

If you just do the Server.Transfer , the new page will got through all the
page processing stages and if Doctype originally exists, it will also be
rendered.

For the new question about "how to detect if Doctype exists before render",
I think this is quite limited because the DocType is only stored in aspx
template file which is loaded the rendering stage.

I have performed some further test on this. Actually, for the "DocType"
section, the ASP.NET page will generate an Literalcontrol which used to
contains the html at the begining of the aspx template file. However, the
LiteralControl' s Text content is not populated before rendering(I've tried
access it and print its content). therefore, I think so far for
manipulating doctype, the following approaches should be the reasonable
ones:

** manually put a Literal control in page template to set the doctype

** use Render method to manipulate it.

If you have any other consideration, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "WT" <WT@newsgroups. nospam>
References: <F6************ *************** *******@microso ft.com>
<6b************ **@TK2MSFTNGHUB 02.phx.gbl>
>In-Reply-To: <6b************ **@TK2MSFTNGHUB 02.phx.gbl>
Subject: Re: Setting Doctype from codebehind ?
Date: Mon, 19 May 2008 14:41:25 +0200
>
Hi Steven,

Thanks, your solution seems good.
Do you know a way to detect in codebehind if DocType is set or not in the
current aspx ?

For subs question, Yes I am doing a Server.Transfer from a std
Default.aspx
>to a std aspx page.

Thanks again.
CS

"Steven Cheng [MSFT]" <st*****@online .microsoft.coma écrit dans le
message
>de news:6b******** ********@TK2MSF TNGHUB02.phx.gb l...
>Hi CS,

As for the DocType, a simple way to set it via codebehind is declare an
ASP.NET LIteral control in aspx template so that you can assign the doc
type string via Literal control's Text property e.g.
=========aspx= ==============
<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="_Def ault" %>
<asp:literal runat="server" id="dt"></asp:literal>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

============== code behind=========

protected void Page_Load(objec t sender, EventArgs e)
{
this.dt.Text= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d\">";

}
============== ========

Alexey also provided an article which mentioned overriding pages' render
method to write the doctype(or any other output content).

For the subidiary question " if I do a server transfert in my codebehind,
do I need any Doctype or html tags in the page ?", I'm not very sure what
is the exact things you want to do, would you provide some further
description on this? Are you performing some server-side redirection like
Server.Transfe r?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

============== =============== =============== ======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
>where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
>up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
============== =============== =============== ======
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>>>From: "WT" <WT@newsgroups. nospam>
Subject: Setting Doctype from codebehind ?
Date: Fri, 16 May 2008 12:57:02 +0200
>>>
Hello,

I am searching for a way to generate automatically from codebehind the
<!Doctype... .for asp.net pages using .net 3.5 c# and vs2008.
Subidiary question: if I do a server transfert in my codebehind, do I
need
>>>any Doctype or html tags in the page ?

Thanks
CS


Jun 27 '08 #6
On May 20, 4:59*am, stch...@online. microsoft.com (Steven Cheng [MSFT])
wrote:
Thanks for your reply CS,

If you just do the Server.Transfer , the new page will got through all the
page processing stages and if Doctype originally exists, it will also be
rendered.

For the new question about "how to detect if Doctype exists before render",
I think this is quite limited because the DocType is only stored in aspx
template file which is loaded the rendering stage. *

I have performed some further test on this. Actually, for the "DocType"
section, the ASP.NET page will generate an Literalcontrol which used to
contains the html at the begining of the aspx template file. *However, the
LiteralControl' s Text content is not populated before rendering(I've tried
access it and print its content). *therefore, I think so far for
manipulating doctype, the following approaches should be the reasonable
ones:

** manually put a Literal control in page template to set the doctype

** use Render method to manipulate it.

If you have any other consideration, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer tohttp://msdn.microsoft. com/subscriptions/managednewsgrou ps/default.asp...
ications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights..

-------------------->From: "WT" <W...@newsgroup s.nospam>
References: <F6455E5F-812C-4EAF-B197-6EEEF1797...@mi crosoft.com>

<6b#DvAWuIHA.5. ..@TK2MSFTNGHUB 02.phx.gbl>


In-Reply-To: <6b#DvAWuIHA.5. ..@TK2MSFTNGHUB 02.phx.gbl>
Subject: Re: Setting Doctype from codebehind ?
Date: Mon, 19 May 2008 14:41:25 +0200
Hi Steven,
Thanks, your solution seems good.
Do you know a way to detect in codebehind if DocType is set or not in the
current aspx ?
For subs question, Yes I am doing a Server.Transfer from a std
Default.aspx
to a std aspx page.
Thanks again.
CS
"Steven Cheng [MSFT]" <stch...@online .microsoft.coma écrit dans le
message
denews:6b****** **********@TK2M SFTNGHUB02.phx. gbl...
Hi CS,
As for the DocType, a simple way to set it via codebehind is declare an
ASP.NET LIteral control in aspx template so that you can assign the doc
type string via Literal control's Text property e.g.
=========aspx== =============
<%@ Page Language="C#" AutoEventWireup ="true" *CodeFile="Defa ult.aspx.cs"
Inherits="_Defa ult" %>
<asp:literal runat="server" id="dt"></asp:literal>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
==============c ode behind=========
protected void Page_Load(objec t sender, EventArgs e)
* *{
* * * *this.dt.Text= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d\">";
}
=============== =======
Alexey also provided an article which mentioned overriding pages' render
method to write the doctype(or any other output content).
For the subidiary question " if I do a server transfert in my codebehind,
do I need any Doctype or html tags in the page ?", I'm not very sure what
is the exact things you want to do, would you provide some further
description on this? Are you performing some server-side redirection like
Server.Transfer ?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsof t.com.
=============== =============== =============== =====
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ps/default.asp...
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
From: "WT" <W...@newsgroup s.nospam>
Subject: Setting Doctype from codebehind ?
Date: Fri, 16 May 2008 12:57:02 +0200
>>Hello,
>>I am searching for a way to generate automatically from codebehind the
<!Doctype.... for asp.net pages using .net 3.5 c# and vs2008.
Subidiary question: if I do a server transfert in my codebehind, do I
need
>>any Doctype or html tags in the page ?
>>Thanks
CS- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
I agree with Steven
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1014
by: Amir Eshterayeh | last post by:
Dear Friends Hope things goes well to you. I have this problem. Would you please give me your solution? I want to change a property that I define on my user control in my web form that contains that user control. but when I want to set the property of user control at my web form, got this error c:\inetpub\wwwroot\test4\WebForm1.aspx.vb(19): Name 'Uc1' is not declared. How can I solve this problem. Please help.
1
2583
by: CES | last post by:
All, Could someone please point me to a step by step resource on setting up a ..net Web Application on IIS. I'm having a problem setting up IIS to except a new Web Application. I'm deploying the default Asp.net Web Application as is setup by VStudio with no code changed, other then adding "Hello World to the <title> tag. I've been able to narrow down the problem to IIS by compiling the Application and deploying it to my production...
3
1589
by: nevets2001uk | last post by:
Hi. I've just started my second ASP.NET (VB) app and I'm using codebehind this time. I'm not using visual studio but am instead coding it all in notepad (HTML, ASP.NET and CSS) I'm trying to understand how to best use codebehind to do what I want to achieve. Basically, so far I have a codebehind file for one page which works as I wanted but I want other pages to share that codebehind file. That's no problem except I want each one to...
1
1531
by: Kenneth Keeley | last post by:
Hi, How do I set the DocType the Asp.net will use when it creates the html the is sent to the client. I wish to create all my pages to a known standard, mostly HTML 4.01 and I have found that Asp.Net pages don't always validate. Is there a global setting that needs to be set or do I have to do it in every page. I am currently using Web Matrix to create my asp.net pages while I am learning. Is this where the problem is? Thanks for any...
12
4910
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function cmdButton1_Clicked() { document.all('txtInput1').focus(); return false; }
2
1280
by: SJ | last post by:
Hi, i'm trying to use codebehind to setup my dropdowns. myWebFile.aspx has the following code : <asp:DropDownList id=test runat=server /> <asp:DropDownList id=test2 runat=server /> And i'm defining the ListItems like this in codebehind:
2
3357
by: DC | last post by:
Hi, I want to keep all my layout information in the .ascx file of a UserControl. If I require layout related data in codebehind, I would usually use properties defined in the codebehind, e.g. string tdStyle; public string TdStyle {
3
2531
by: danmc91 | last post by:
Hello, I'm new to xml and xslt but that should be obvious from my question. I'm trying to help my wife set up some web pages with some of her art work and what I'm trying to do is find a way to get all of the information about the pictures in an XML file and then use xslt to produce some different html files. My first problem is I can't seem to figure out how to get this to
4
10123
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using a I frame in a page and trying to set the height to height=100% and it is not working. If I use height=600px it works. I find some stuff about the DOCTYPE on the internet but changing the doctype does not work. Maybe I am using the incorrect doctype. This line works: <iframe id="fraAdmin" width=100% height:600px;" visible="true" runat="server" ></iframe>
0
9571
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,...
0
10561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
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...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9132
agi2029
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...
0
6845
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();...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.