Asp.net master.cs文件无法识别master.aspx页中存在的控件 [英] Asp.net master.cs file not identifying the controls present in master.aspx page
本文介绍了Asp.net master.cs文件无法识别master.aspx页中存在的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试使用它时,我在master.aspx页面中创建了一个标签控件....在文件(master.cs)后面的代码中.在当前上下文中不存在".不仅在我尝试在.cs文件中使用时标记任何控件,还显示控件不存在" ...正在努力寻求帮助吗?
我的代码如下.
I have created a label control in my master.aspx page....in my code behind file(master.cs) when Iam trying to use it..it''s throwing error like--- "the control does not exist in the current context"..not only label any control when I try to use in .cs file it''s showing ''control does not exist" ...struggling any help?
my code as follows..
codebehind file<br />
----------------<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
public partial class SprintSafety : System.Web.UI.MasterPage<br />
{<br />
SprintSafetyDataContext objc = new SprintSafetyDataContext();<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
<br />
if (Session[&quot;JID&quot;] != null)<br />
{<br />
string s = Session[&quot;JID&quot;].ToString();<br />
var a = (from selecteddata in objc.tblJobs where selecteddata.ID == Convert.ToInt32(s) select selecteddata.JobName).FirstOrDefault();<br />
error ------> lblJobid.Text = a.ToString();<br />
<br />
}<br />
}<br />
}<br />
<code><br />
<br />
<pre>&lt;pre lang=&quot;msil&quot;&gt;showing error<br />
---------------<br />
Error 6 The name &amp;#39;lblJobid&amp;#39; does not exist in the current context D:\pradeep2\SprintSafety\SprintSafety.master.cs 22&lt;/pre&gt;<br />
my label control in master.aspx page<br />
----------------------------------------<br />
my label control in master.aspx page<br />
----------------------------------------<br />
<br />
<br />
<div class="butt_main_inner"><br />
<asp:Label ID="lblJobid" Text="" runat="server" /></div><br />
---<br />
-----<br />
----------</pre>
推荐答案
我相信这可以回答您的问题:
如何:参考ASP.NET母版页内容 [
I believe this answers your question:
How to: Reference ASP.NET Master Page Content[^]
Best regards
Espen Harlinn
这篇关于Asp.net master.cs文件无法识别master.aspx页中存在的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文