以编程方式设置页面标题和/或隐藏表单字段? [英] Programatically set the Page Title and/or Hidden Form Field?

查看:71
本文介绍了以编程方式设置页面标题和/或隐藏表单字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过ASP.Net以编程方式设置页面标题和/或表单隐藏字段




我不想使用某些东西喜欢...

<%sTitle =" My Title" %>

< html>< title><%= sTitle%>< / title> .....


我想要从演示文稿中完全分离代码。


我想对隐藏表单字段的值做同样的事情,但

就像标题一样,我不想做类似下面的事情:

< input type =" hidden" ID = QUOT; HiddenField" value ="<%= sHiddenFieldValue%>">


我可以通过编程或某些服务器控件设置这些值吗?


TIA

I want to set the page title and/or a form hidden field programatically
through ASP.Net.

I do not want to use something like...
<% sTitle ="My Title" %>
<html><title><%=sTitle%></title>.....

I want to completely seperate the code from presentation.

I would like to do the same thing for a value of a hidden form field but
like the title, I do not want to do something like below:
<input type="hidden" id="HiddenField" value="<%=sHiddenFieldValue%>">

Can I set these values programaically or though some Server Controls?

TIA

推荐答案

你好Paul,


这里有一种使用codebehind设置标题的方法。

http://authors.aspalliance.com /kenc/faq5.aspx


Ken


" Paul" <帕** @ discussions.microsoft.com>在消息中写道

新闻:1E ********************************** @ microsof t.com ...
Hi Paul,

Here''s a way to set the title using codebehind.

http://authors.aspalliance.com/kenc/faq5.aspx

Ken

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
我想通过ASP.Net以编程方式设置页面标题和/或表单隐藏字段。

我不想要使用类似......
<%sTitle =" My Title" %>
< html>< title><%= sTitle%>< / title> .....

我想从演示文稿中完全分离代码。

我想对隐藏表单字段的值做同样的事情但是像标题一样,我不想做类似下面的事情:
< input type =" hidden" ID = QUOT; HiddenField" value ="<%= sHiddenFieldValue%>">

我可以通过编程或某些服务器控件来设置这些值吗?

TIA
I want to set the page title and/or a form hidden field programatically
through ASP.Net.

I do not want to use something like...
<% sTitle ="My Title" %>
<html><title><%=sTitle%></title>.....

I want to completely seperate the code from presentation.

I would like to do the same thing for a value of a hidden form field but
like the title, I do not want to do something like below:
<input type="hidden" id="HiddenField" value="<%=sHiddenFieldValue%>">

Can I set these values programaically or though some Server Controls?

TIA



Paul,


我倾向于使用这种机制


for Title

< Title id =" objTitle" runat =" server">< / title>


代码在页面后面添加

HtmlGenericControl objTitle;

to数据库列表。


现在您可以在代码后面以编程方式访问它

同样适用于隐藏字段

<输入类型= QUOT;隐藏"名称= QUOT; objHiddenField" id =" name =" objHiddenField"

runat =" server">


代码隐藏此应自动显示在数据库列表中为

HtmlInputHidden objHiddenField;


如果您没有看到它添加它,就像您添加上面显示的titleobject一样。现在你

也可以通过编程方式访问它


HTH


问候,

Hermit Dave
http://hdave.blogspot.com


" Paul"写道:
Paul,

I tend to use this mechanism

for Title
<Title id="objTitle" runat="server"></Title>

on code behind page add
HtmlGenericControl objTitle;
to the datamembers list.

now you can access it programmatically in code behind
same goes for hidden field
<input type="hidden" name="objHiddenField" id="name="objHiddenField"
runat="server">

on codebehind this should automatically appear in datamembers list as
HtmlInputHidden objHiddenField;

if you dont see it add it the way you add titleobject shown above. Now you
can access it programmatically as well

HTH

Regards,

Hermit Dave
http://hdave.blogspot.com

"Paul" wrote:
我想通过ASP.Net以编程方式设置页面标题和/或表单隐藏字段。

我不想要使用类似......
<%sTitle =" My Title" %>
< html>< title><%= sTitle%>< / title> .....

我想从演示文稿中完全分离代码。

我想对隐藏表单字段的值做同样的事情但是像标题一样,我不想做类似下面的事情:
< input type =" hidden" ID = QUOT; HiddenField" value ="<%= sHiddenFieldValue%>">

我可以通过编程或某些服务器控件来设置这些值吗?

TIA
I want to set the page title and/or a form hidden field programatically
through ASP.Net.

I do not want to use something like...
<% sTitle ="My Title" %>
<html><title><%=sTitle%></title>.....

I want to completely seperate the code from presentation.

I would like to do the same thing for a value of a hidden form field but
like the title, I do not want to do something like below:
<input type="hidden" id="HiddenField" value="<%=sHiddenFieldValue%>">

Can I set these values programaically or though some Server Controls?

TIA



戴夫,


我常常想知道为什么有人会经历

的麻烦以编程方式设置页面标题,如果页面标题不能动态更改,则为



如果我正在做的就是设置一个固定的标题,为什么我要这样做?

(除了浪费宝贵的编程和处理时间。)


写标题不是更简单在aspx页面中?


在代码隐藏中设置页面标题可以获得什么?


Juan T. Llibre

ASP.NET MVP
http://asp.net.do / foros /

Foros de ASP.NET en Espa?ol

Ven,y hablemos de ASP.NET ...

======================

" Hermit Dave" <他************ @ CAPS.AND.DOTS.hotmail.com>在消息中写道

news:83 ********************************** @ microsof t.com ...
Dave,

I''ve often wondered why anybody would go through
the trouble of setting a Page Title programmatically,
if the Page Title can''t be changed dynamically.

If all I''m doing is setting a fixed title, why would I want to do that ?
( Except to waste valuable programming and processing time. )

Isn''t it simpler to write the title in the aspx page ?

What is gained by setting a Page Title in code-behind ?

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa?ol
Ven, y hablemos de ASP.NET...
======================

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:83**********************************@microsof t.com...
Paul,

我倾向于使用这个机制

标题
< Title id =" ; objTitle" runat =" server">< / title>
在页面后面的代码中添加
HtmlGenericControl objTitle;
到datamembers列表。

现在你可以在代码后面以编程方式访问它
同样适用于隐藏字段
< input type =" hidden"名称= QUOT; objHiddenField"对于代码隐藏,id =" name =" objHiddenField"
runat =" server">

这将自动出现在数据库列表中作为HtmlInputHidden objHiddenField;

如果您没有看到它添加它,就像您添加上面显示的titleobject一样。现在你也可以通过编程方式访问它。

HTH

问候,

Hermit Dave
http://hdave.blogspot.com

保罗写道:
Paul,

I tend to use this mechanism

for Title
<Title id="objTitle" runat="server"></Title>

on code behind page add
HtmlGenericControl objTitle;
to the datamembers list.

now you can access it programmatically in code behind
same goes for hidden field
<input type="hidden" name="objHiddenField" id="name="objHiddenField"
runat="server">

on codebehind this should automatically appear in datamembers list as
HtmlInputHidden objHiddenField;

if you dont see it add it the way you add titleobject shown above. Now you
can access it programmatically as well

HTH

Regards,

Hermit Dave
http://hdave.blogspot.com

"Paul" wrote:
我想通过ASP.Net以编程方式设置页面标题和/或表单隐藏字段。

我不想要使用类似......
<%sTitle =" My Title" %>
< html>< title><%= sTitle%>< / title> .....

我想从演示文稿中完全分离代码。

我想对隐藏表单字段的值做同样的事情但是像标题一样,我不想做类似下面的事情:
< input type =" hidden" ID = QUOT; HiddenField" value ="<%= sHiddenFieldValue%>">

我可以通过编程或某些服务器控件来设置这些值吗?

TIA
I want to set the page title and/or a form hidden field programatically
through ASP.Net.

I do not want to use something like...
<% sTitle ="My Title" %>
<html><title><%=sTitle%></title>.....

I want to completely seperate the code from presentation.

I would like to do the same thing for a value of a hidden form field but
like the title, I do not want to do something like below:
<input type="hidden" id="HiddenField" value="<%=sHiddenFieldValue%>">

Can I set these values programaically or though some Server Controls?

TIA



这篇关于以编程方式设置页面标题和/或隐藏表单字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆