473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Setting Doctype from codebehind ?

WT
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 #1
6 7921
On May 16, 12:57*pm, "WT" <W...@newsgroups.nospamwrote:
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
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="Default.aspx.cs"
Inherits="_Default" %>
<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(object 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.dtd\">";

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

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****@microsoft.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 #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****************@TK2MSFTNGHUB02.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="Default.aspx.cs"
Inherits="_Default" %>
<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(object 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.dtd\">";

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

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****@microsoft.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**********************************@m73g2000 hsh.googlegroups.com...
On May 16, 12:57 pm, "WT" <W...@newsgroups.nospamwrote:
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
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****@microsoft.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**********************************@microsoft.co m>
<6b**************@TK2MSFTNGHUB02.phx.gbl>
>In-Reply-To: <6b**************@TK2MSFTNGHUB02.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****************@TK2MSFTNGHUB02.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="Default.aspx.cs"
Inherits="_Default" %>
<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(object 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.dtd\">";

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

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****@microsoft.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...@microsoft.com.

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

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

-------------------->From: "WT" <W...@newsgroups.nospam>
References: <F6455E5F-812C-4EAF-B197-6EEEF1797...@microsoft.com>

<6b#DvAWuIHA.5...@TK2MSFTNGHUB02.phx.gbl>


In-Reply-To: <6b#DvAWuIHA.5...@TK2MSFTNGHUB02.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****************@TK2MSFTNGHUB02.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="Default.aspx.cs"
Inherits="_Default" %>
<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(object 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.dtd\">";
}
======================
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...@microsoft.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...@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- 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
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...
1
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...
3
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...
1
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...
12
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...
2
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...
2
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. ...
3
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...
4
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.