InitializeControl doesn't exsit

When using visual studio 2012 for developing
SharePoint 2013 Visual web parts either of type sandbox solution or farm
solution you might face a the following error:

“The name InitializeControl” does not exist with
the current context”

 
Before describing the solution lets first describe
the error, as shown in the image above this error occurs on the OnInit
Method.
About OnInit: OnInit
method is part of the web part life cycle, which is responsible for
initialization the controls inside the web part (as example label, button, textbox and
others).
By mapping between the error and the OnInite method
you will realize that this issue relates to controls inside the web
part.
By checking the visual web part, I found that the
designer file of type “ascx.g.cs” is missing, this file is responsible for
drawing the controls that are mapped with the visual web
part.
 

This issue
could occur by two reasons, as follows

1.The
solution is not using an existing or valid URL, by checking the SharePoint URL
please make sure that the URL is valid and exists, try to map the URL and build
your solution and check the result if the error still
exists.
 
2.If
the error still exists and the URL you are using is correct then we will do some
manual steps on top of visual studio as follows
a.Right click on you SharePoint project and then add
new item
b.Add
user control as shown below, its better to name this user control by the same
name of your visual web part, as example if your web part called Visual Web part
1, then for the User control name it as Visual Web part 1
 
 
 

c.The
user control will resides under the ControlTemplates folder (Mapped folder) as
shown below

 
d.Under the visual web part “VisualWebPart1” make
sure to delete the “VisualWebPart1.ascx” as shown below
 
 

e.
Then
we will drag the VisualWebPart1.ascx that resides in the ControlTemplates folder
and drop it under the VisualWebPart1 , this will add the new user control
including its designer under the VisualWebPart1, your solution should look like
below

f.  
Now try to add “Label” as example and build your solution, the result is
great and the error has gone.

The Question is: do we need to
repeat same steps for any new visual web part?
The answer is No, simply you can remove
the old web part , then add a new visual web part and the Visual Studio will
automatically create the “ascx.designer.cs” file for you ,so consider your
visual was stuck but then it works properly.

referring to:http://samer-othman.blogspot.com/2013/03/how-to-fix-error-name-initializecontrol.html

.ascx.g.cs文件不能生成 The name ‘InitializeControl’ does not exist in the current context - Visual Web part Sharepoint的更多相关文章

  1. Day Tip:SharePoint 2013 *.ascx.g.cs文件

    在开发SharePoint2013的WebPart时,会产生一个*.ascx.g.cs文件.如果用TFS管理源代码经常遇到这个文件丢失.这让人很困扰,如果丢失了请在如下图中添加如下代码:       ...

  2. C# 调用WebService的3种方式 :直接调用、根据wsdl生成webservice的.cs文件及生成dll调用、动态调用

    1.直接调用 已知webservice路径,则可以直接 添加服务引用--高级--添加web引用 直接输入webservice URL.这个比较常见也很简单 即有完整的webservice文件目录如下图 ...

  3. 根据wsdl文件生成webservice 的.cs文件 及 生成dll C#调用

               Visual Studio 2013->Visual Studio Tools->VS2013 开发人员命令提示 命令行输入 wsdl E:\WS.wsdl /out ...

  4. 2014-08-22 关于Response、Request等对象在cs文件中的使用

    今天是在吾索实习的第33天.已经有一段时间没写过博客了,今天突然想起个值得分享的东西,所以又华丽地回归了. 废话不多说了,直奔主题.我们会发现,在我们在cs文件中,直接使用Response.Reque ...

  5. WPF根据Oracle数据库的表,生成CS文件小工具

    开发小工具的原因: 1.我们公司的开发是客户端用C#,服务端用Java,前后台在通讯交互的时候,会用到Oracle数据库的字段,因为服务器端有公司总经理开发的一个根据Oracle数据库的表生成的cla ...

  6. .wsdl文件生成.cs文件

    1.打开VS文件命令行工具(一般在安装文件的Common7\Tools\Shortcuts下面例如[E:\VS2013安装程序\Common7\Tools\Shortcuts\VS2013 x64 本 ...

  7. VS2010 根据WSDL文件(java Web Service)生成.cs文件

    我们添加webService引用,一般是通过 添加服务引用完成的,其实 添加服务引用 在背后为我们生成了代理类. 我们手动生成代理类方法: 1.通过java Web Service,生成wsdl文件: ...

  8. 用csc命令行手动编译cs文件

    一般初学c#时,用记事本写代码,然后用命令行执行csc命令行可以编译cs文件.方法有两种 1:配置环境,一劳永逸 一般来说在C:\Windows\Microsoft.NET\Framework\v4. ...

  9. 为何没有.aspx.designer.cs文件?

    designer.cs 是窗体设计器生成的代码文件,作用是对窗体上的控件做初始化工作(在函数InitializeComponent()中)VS2003以前都把这部分代码放到窗体的cs文件中,由于这部分 ...

随机推荐

  1. 单选按钮,通过js判断是否选中

    <input type="radio" value="0" style="vertical-align:middle" name=&q ...

  2. X230上安装Yosemite/Win7-黑苹果之路

    以前曾经在X230上安装了mavericks,但因为无线网卡问题最终作罢,现在换了SSD(128G).AR9285网卡,又冲刺了一把OSX,折腾了好几天,终于成了.特做记录如下: 首先,硬盘分区问题, ...

  3. Redis多机功能总结

    1.通过Redis的复制功能,用户可以创建指定服务器的任意多个复制品,每个复制品服务器和被复制的原服务器拥有相同的数据: 2.通过将读请求分散给多个从服务器处理,用户可以减少主服务器在处理读请求方面的 ...

  4. SparkSQL使用之Thrift JDBC server

    Thrift JDBC Server描述 Thrift JDBC Server使用的是HIVE0.12的HiveServer2实现.能够使用Spark或者hive0.12版本的beeline脚本与JD ...

  5. android下拉菜单 spinner 学习

    首先看一下继承关系: public class Spinner extends AbsSpinner implements DialogInterface.OnClickListener Class ...

  6. POJ1298_The Hardest Problem Ever_最难的问题_Caesar 密码_C++

    题目:http://poj.org/problem?id=1298 好吧,给了题目也看不懂……给出翻译(题目名翻译是:最难的问题,233333) 这一看就是老师给出题解: 然而没有什么用哈 最快的办法 ...

  7. 【转贴】全站 HTTPS 来了

    http://geek.csdn.net/news/detail/48765 作者:腾讯TEG架构平台部静态加速组高级工程师 刘强 最近大家在使用百度.谷歌或淘宝的时候,是不是注意浏览器左上角已经全部 ...

  8. oracle删除用户及其名下对象

    drop user XXXX cascade; drop tablespace XXXX INCLUDING CONTENTS;

  9. Unable to load type System.Data.Entity.DynamicProxiesXXXXXrequired for deserialization.

    Memcache实例的Get方法时抛出了异常“Unable to load type System.Data.Entity.DynamicProxies.AdInfoItems_19CD09C8E46 ...

  10. 洛谷P2722 总分 Score Inflation

    P2722 总分 Score Inflation 184通过 295提交 题目提供者该用户不存在 标签USACO 难度普及- 提交  讨论  题解 最新讨论 关于算法 题目背景 学生在我们USACO的 ...