Sharepoint visual web part

Hello, I would like to create visual web part, that can be used within SharePoint LIST's edit item form...I want to include treeview into the webpart and load a directory structure to it...a direcotry structure is meant a Folder hierarchy from fileprint
server - share.
to browse through share I use:
stringsourcePath
="D:\\";
foreach(stringdr
inSystem.IO.Directory.GetDirectories(sourcePath))
but I am receiving this error:
An exception of type 'System.Security.SecurityException' occurred in prva.dll but was not handled in user code
Additional information: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
stack trace:
   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
   at System.Security.CodeAccessPermission.Demand()
   at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
   at System.IO.Directory.GetDirectories(String path, String searchPattern, SearchOption searchOption)
   at System.IO.Directory.GetDirectories(String path)
   at prva.VisualWebPart1.VisualWebPart1.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
please, help if possible

You code failes because of security permission,set <trust level="Full" />
see these threads, should help you to resolve
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/3c10b18b-b098-4967-8664-137bee9c2dcc/request-for-the-permission-of-type-fileiopermission-failed?forum=sharepointdevelopmentlegacy
http://forums.asp.net/t/1422162.aspx?System+Security+SecurityException+Request+for+the+permission+of+type+System+Security+Permissions+FileIOPermission+mscorlib+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failed+
Hope this helps!
Ram - SharePoint Architect
Blog - SharePointDeveloper.in
Please vote or mark your question answered, if my reply helps you

Similar Messages

  • SharePoint visual web part project creation usng TFS2010

    Hi,
    I have configured TFS2010 in SharePoint 2010 server and used TFS url in client machine.
    From client machine i am able to create new TFS project, but i cannot find information's to create SharePoint project using VS2010 SharePoint templates?
    How to create Visual web part project using TFS2010?
    Anandhan.S Remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    Hi,
    According to your post, my understanding is that you wanted to create SharePoint project using the TFS 2010.
    Did you install the Build Support for Apps for Office and Apps for SharePoint?
    To build apps for Office and apps for SharePoint projects, several components must be installed on your system.
    What’s more, we should copy several Visual Studio SharePoint assemblies to the GAC on the build server.
    Copy the SharePoint Tool Assemblies and Files to the GAC
    The following assemblies must be copied to the GAC of the build system:
    Microsoft.VisualStudio.SharePoint.Designers.Models.dll
    Microsoft.VisualStudio.SharePoint.Designers.Models.Features.dll
    Microsoft.VisualStudio.SharePoint.Designers.Models.Packages.dll      Microsoft.VisualStudio.SharePoint.dll
    There are two articles about building SharePoint 2010 solutions on TFS 2010, I think it’s helpful for your to create project in TFS2010.
    http://msdn.microsoft.com/en-us/library/ff622991.aspx
    http://blogs.msdn.com/b/jjameson/archive/2011/02/27/building-sharepoint-2010-solutions-on-a-tfs-2010-build-server.aspx
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • How to Add a User Control to a SharePoint 2013 Visual Web Part ?

    Hi,
    1.I have created SharePoint 2013 Farm Solution through VS 2012.
    2.Added visual Web part
    3.Created a User control (Farm Solution ) and added some Control From tool Box.
    4.Drag and drop user control from solution explorer to visual web part.
    so its  Register tag and with prefix tag user controls automatically added on visual web part source. when i try to build solution it throws Exception:
    Exception :The name 'InitializeControl' does not exist in the current context.
    Please Provide solution after try/or proper workaround.
    Thanks,
    Siddheshwar

    Site name=http://sitename:22222/
    Visual Web part:
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Src="~/_controltemplates/15/SP2013Controls/SPControls.ascx" TagPrefix="uc1" TagName="SPControls" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SPWebpart.ascx.cs" Inherits="SP2013Controls.SPWebpart.SPWebpart" %>
    <uc1:SPControls runat="server" id="SPControls" />
    User Control Code:
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SPControls.ascx.cs" Inherits="SP2013Controls.ControlTemplates.SP2013Controls.SPControls" %>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="Button" />
    Deployement Location:{SharePointRoot}\Template\ControlTemplates\SP2013Controls\
    After User controls added on webpart .g.cs file getting blank.
    After 1st Build:
    'InitializeControl' does not exist in the current context
    The file '/_controltemplates/15/SP2013Controls/SPControls.ascx' does not exist.
    after 2nd Build Try:
    'InitializeControl' does not exist in the current context

  • Create a visual web part which get data from excel sheet and import it into sql server database in sharepoint 2010 (development)

    Hi,
    I want to create a visual webpart which will read data from excel sheet and import it in to sql server database.(using sharepoint development)
    I want to do it using visual webpart.
    Please help to solve the issue.
    Thanks in advance!
    Regards
    Rajni

    Hi  Rajni,
    Microsoft.Office.Interop.Excel assembly provides class to read excel file data, in your web part solution, reference the assembly, and following blog contains samples about how to read the excel file data,
    and import it to SQL  database.
    1.Create a Visual Web Part Project:Create
    Visual Web Parts in SharePoint 2010
    2.Read the excel workbook by using SPFile class:
    http://alancejacob.blogspot.in/2012/06/read-data-from-excel-file-and-insert-in.html
    http://stackoverflow.com/questions/14496608/read-excel-file-stored-in-sharepoint-document-library
    3.Export the excel workbook to SQL Server:
    http://www.c-sharpcorner.com/UploadFile/99bb20/import-excel-data-to-sql-server-in-Asp-Net/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Way to use Visual Web part in sharepoint 2010 without using/installing third party tools

    I want to know the way to use Visual Web part in sharepoint 2010 without using/installing third party tools.
    Please provide me a link where i can actually know how it is done.

    + to _eNo_,
    Visual Studio 2010 has support for visual webpart, you can find that under Visual C# node in the Installed Templates section (if your preferred language is C#)
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Sharepoint 2013 Visual Web part Deloyment

    Hello,
    I built a visual web part(sharepoint 2013) using visual studio 2012. But when I tried deploying, I got this error message:
    "Error occured in deployment step 'Activate Features': Feature id '****' is not installed in this farm, and cannot be added to this".
    Approaches I made to fix this :
    1) Tried changing the scope of Feature to Farm/Web/WebApplication
    2) Tried installing feature manually using Install-SPFeature -AllExistingFeatures
    3) Tried resetting IIS
    None of these attempts helped me. Can someone help me on this ?
    Thanks
    KG

    Hi,
    According to your post, my understanding is that you get error while deploying the visual web part.
    To narrow down whether the issue is related to the project itself, you can do some steps as below.
    Re-open the visual studio, create a new clean project with a simple visual web part then check whether it works.
     What’s more, you can check whether feature assembly is register in GAC or not. So try to uninstall feature and use below command: (if have not done before)
    Install-SPSolution -Identity MYfeature.wsp  -GACDeployment -force
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • SharePoint 2013 Visual Web Part Custom Property.

     How to create drop down control to display existing libraries in current web site using a custom web part property?i want to show this control on web part configuration.then users can select the relevant library without typing.(SharePoint
    2013 Visual Web Part).
    Thanks 

    This has been answered for SP 2010 at SP:SO. Things wont change much in SP 2013 as far as VWP is concerned. Basically you will need to implement Custom Web Part Editor.
    http://stackoverflow.com/questions/6946153/edit-webpart-properties-with-dynamic-dropdownlist
    Here is an example.
    http://sptechbytes.blogspot.ca/2013/02/sharepoint-2010-creating-custom-editor.html
    Amit

  • How to display alert message box in sharepoint 2013 visual web part?

    Hi,
    I am developing a visual web part which submits data to the list. Once it submits the data, I should convey to the user that the data has been submitted successfully.
    I tried using clientScript.RegisterStartUpScript etc, but, none of them are working. It is not throwing any error , but pop up is not getting displayed.
    Preferrably, I would like to call this alert message from cs page, because, I will be using it in several places.
    Please help me.!
    Thanks in advance.
    Hepsi

    Hepsi, 
    Step 1. On the Page_Load - This way you can pass parameters. Try this
    btn.Attributes.Add(
    "onclick", string.Format("return openSPPopup('{0}?{1}={2}', '{3}')", YourPage_URL, var1_Name, value1, Param1_PopupTitle));
    Step 2 : Javascript function
    function openSPPopup(navigateURL, popUptitle) {
    var options = {
    width: popupWidth,
    height: popupHeight,
    url: navigateURL,
    scroll: 0
    SP.UI.ModalDialog.showModalDialog(options);
    return false;
    Step 3: The popup close code (in .cs file) – I do it this way as it is just close dialog code and easy to write.
    protected void btnClose_Click(object sender, EventArgs e)
    { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "SP.UI.ModalDialog.commonModalDialogClose(1, 1);", true);
    Courtesy -
    Thread
    Try this - https://bramdejager.wordpress.com/2011/03/21/using-sp-ui-dialog-and-sp-ui-notify-from-code-behind/
    http://msdn.microsoft.com/en-us/library/ff798390.aspx
    http://stackoverflow.com/questions/9833907/asp-net-confirm-before-executing-codebehind
    http://www.codeproject.com/Questions/443131/Call-to-javascript-Function-from-code-behind-using
    http://www.c-sharpcorner.com/uploadfile/ledomoon/calling-code-behind-function-in-javascript/
    Hope they will help!
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • Create a Site Definition file with Visual Web part in Visual Studio

    I tried to create a site definition file in Visual Studio 2013 and SharePoint 2013 by following the MSDN tutorial:
    Walkthrough: Create a Basic Site Definition Project. Near the end, I added a virtual web part control to the site definition and registered MyWebPartControls in the site definition's default ASPX page as written in the MSDN tutorial:
    Unfortunately, IntelliSense doesn't show any MyWebPartControls: tags, and VisualWebPart1 is highlighted with a warning “Element 'SMWebPart3' is not a known element. This can
    occur if there is a compilation error in the Web site, or the web.config file is missing.”
    Since it’s a warning, I went ahead to build and deploy the solution. However, when I used the site definition template to create a subsite, it returned a parser error:
    Unknown server tag 'MyWebPartControls:TestSiteDef1.VisualWebPart1'
    I spent half day researching and debugging, and finally solved the problem. The issue is on the registration line:
    <%@ Register Tagprefix="MyWebPartControls" Namespace="TestSiteDef.VisualWebPart1" Assembly="$SharePoint.Project.AssemblyFullName$" %>
    The $SharePoint.Project.AssemblyFullName$ is a replaceable parameter to provide values for SharePoint solution items whose actual values are not known at design time. Unfortunately, it does not find the right assembly name during the deployment. It should
    be replaced by the Assembly’s Strong Name. Here is how I fixed the problem step by step:
    In Solution Explorer, open the package node and double click Package.package
    Click Manifest tab in the Package.package.
    Copy the full assembly name in the package’s manifest. It may be similar like this:
              Assembly="TestSiteDef,
    Version=1.0.0.0, Culture=neutral, PublicKeyToken=a300f1f2da8ae976"
    Back to the site definition’s default.aspx page, replace the
                     Assembly="$SharePoint.Project.AssemblyFullName"
    in the registration line with the copied text:
    Assembly="TestSiteDef,
    Version=1.0.0.0, Culture=neutral, PublicKeyToken=a300f1f2da8ae976"
    Change the Namespace from
    Namespace="TestSiteDef.VisualWebPart1"
    to
    Namespace="TestSiteDef".
    The line to register the web part in a site definition file will look like this:
    <%@
    Register
    Tagprefix="MyWebPartControls"
    Namespace="TestSiteDef "
    Assembly="TestSiteDef, Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=a300f1f2da8ae976"
    %>
    Clean, build and deploy the solution. It works like charm. (Note: the warning message on visual web part may still exist, but you can ignore it).

    Assuming your .ascx.vb file is inheriting from the web part class, you can add the custom properties in the same manor (language syntax aside).
    Be sure to use the attributes to correctly identify and scope the properties. (see:
    http://www.sbrickey.com/Tech/Blog/Post/SharePoint_Attributes_for_Web_Part_properties)
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com

  • Access denied error while adding visual web part

    i am trying to create visual web part using client side code in SharePoint 2013.
    i am able to deploy my web part but when I try to add it on a page it says " Access denied. You do not have permission to perform this action or access this resource" and when i try to debug it it shows exception: "The remote server returned
    an error: (500) Internal Server Error."
    Following is the code:
     protected void Page_Load(object sender, EventArgs e)
                var ClientContext = new ClientContext("http://172.20.30.100:1111/");
                        //SP.ClientContext.get_current();
                Web web = ClientContext.Web;
                ClientContext.Load<Web>(web);
                ClientContext.ExecuteQuery();
                var BU = web.Title;
                ListCollection ListColl = web.Lists;
                List list = ListColl.GetByTitle("LNT_Testimonial");
                CamlQuery CmlQry = new CamlQuery();
                CmlQry.ViewXml = @"<View>
                                        <Query>
                                          <Where>
                                            <Eq>
                                              <FieldRef Name='BU' />
                                              <Value Type='Text'>" + BU + @"</Value>
                                            </Eq>
                                          </Where>
                                        </Query>
                                        <RowLimit>1</RowLimit>
                                      </View>";
                Microsoft.SharePoint.Client.ListItemCollection items = list.GetItems(CmlQry);
                ClientContext.Load<ListCollection>(ListColl);
                ClientContext.Load<List>(list);
                ClientContext.Load<Microsoft.SharePoint.Client.ListItemCollection>(items);
                ClientContext.ExecuteQuery();
                //var testimonial = items.FieldValues["testimonial"];
                foreach (Microsoft.SharePoint.Client.ListItem item in items)
                    var testimonial = item.FieldValues["testimonial"];
    regards, Ritesh Anand

    I'm not sure if you are trying to create visual webpart or doing something else? As I understand from your code, maybe, you are trying to access list item. If you have access to the server (on-premise), you can check the ULS log for details of the error.
    Is it access denied or 'internal server errror'. If it's internal server error then more details can be found in SharePoint ULS log. About reporting service, not sure if it's related to your original question. Please try to use a single post to focus on single
    problem.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

  • Returning Name and Username from People Picker Field in Visual Web Part

    Dear All
    I am creating a visual web part that displays a list that I have created in SharePoint. One of the fields in the list is a People & Groups column type (People Picker) called 'Presented by'. In my web part, I would like to display the username and
    the name of the person who has been 'picked' in this field. However, my using <%# Eval("Presented by") %> only displays their name. How do I get this field to also return their username?
    Many thanks for your help
    Daniel

    You ca  use this code:- change it according to your need
    int requestForUserID = 0;
    string requestForUserLoginName = string.Empty;
    string requestForUserName = string.Empty;
    string userAccount = peoplePickerEmployee.CommaSeparatedAccounts;
    string[] UsersSeperated = peEmployeeOnBehalf.CommaSeparatedAccounts.Split(',');
    foreach (string user in UsersSeperated)
    SPContext.Current.Web.EnsureUser(user);
    SPUser spUser = SPContext.Current.Web.SiteUsers[user];
    requestForUserID = spUser.ID;
    requestForUserLoginName = spUser.LoginName;
    requestForUserName = spUser.Name;
    Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
    INSQLSERVER.COM
    Mohammad Nizamuddin

  • How to create Auto complete text box in share point 2010 Visual web part

    Hi All ,
    I am want to use Auto complete text box in share point 2010 Visual web part ,data need to get from share point list how to  create 
    please guide me how to use Auto complete text box
    Thanking you,
    Arun Darly

    Hi Arun,
    Please refer to the following article.
    SharePoint 2010: JQuery Autocomplete Textbox Containing List Items
    http://smarttools.codeplex.com/wikipage?title=Autocomplete%20Text%20Field
    Please don't forget to mark it as answered, if your problem resolved or helpful.

  • Connectable Visual Web Parts

    Hi..
    how to use Connectable Visual Web Parts in 2 different pages.
    Ravindranath

    The old SharePoint framework has a framework for that, cross/page web part connections:
    http://msdn.microsoft.com/en-us/library/dd585662(v=office.11).aspx I'm not entirely sure if you still can create those kind of web parts in 2010 and you'll have to find that out,
    but the new web part connections framework doesn't support cross-page connections.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • Visual Web Part Value not Selecting in Page Redirection

     Hi..
     I have a Visual Web Part having DropDown Controls and adding Webpart in 3 Web Part Pages .. When we redirect from 1 page to another, the  selected dropdown values are not coming in 2nd and 3rd page..
    Ravindranath

    You have added visual web part in three different pages, drop down value will not be selected when you redirect to page 2 or page 3 because they are separate pages and a separate web parts added on each page. Each page has a separate page life cycle.
    You can only set dropdown value by passing query string parameter.
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer.

  • Export to PDF in Sharepoint Custom web part.

    Hi,
    I want to export my page to pdf in sharepoint custm web part. I am using below code to export to pdf. when i click the export button i am getting below
    Error. how to resolve this error? pLease help me.
    Code
    protected void ExporttoPDF_Click(object sender, EventArgs e)
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=ExporttoPDF.pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                StringWriter sw = new StringWriter();
                HtmlTextWriter hw = new HtmlTextWriter(sw);
                this.Page.RenderControl(hw);
                StringReader sr = new StringReader(sw.ToString());
                Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
                HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                pdfDoc.Open();
                htmlparser.Parse(sr);
                pdfDoc.Close();
                Response.Write(pdfDoc);
                Response.End();
    Error 
    Server Error in '/' Application.
    RegisterForEventValidation can only be called during Render();
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.InvalidOperationException: RegisterForEventValidation can only be called during Render();
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [InvalidOperationException: RegisterForEventValidation can only be called during Render();]
       System.Web.UI.ClientScriptManager.RegisterForEventValidation(String uniqueId, String argument) +11081278
       System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter writer) +455
       System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +27
       System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer) +27
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
       System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
       System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +411
       System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +87
       System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +53
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
       System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
       System.Web.UI.Page.Render(HtmlTextWriter writer) +38
       Microsoft.SharePoint.WebPartPages.WikiEditPage.Render(HtmlTextWriter writer) +207
       PayrollProject.PaySlip4Employee.PaySlip4EmployeeUserControl.btnPDF_Click(Object sender, EventArgs e) +425
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
    Version Information: Microsoft .NET Framework Version:2.0.50727.5472; ASP.NET Version:2.0.50727.5474 

    Hi,
    We know that the Page.EnableEventValidation property is set to true(The default is true.),  Sharepoint Custom web(ASP.NET Web) validates that a control event originated from the user interface that was rendered by that control. A control registers its
    events during rendering and then validates the events during postback or callback handling.
    If you write client script freely,you might have to set "EnableEventValidation = false" in your C# code behind,but this method may be troublesome in SharePoint,
     so the method of "sadomovalex"( http://sadomovalex.blogspot.in/) is a good idea.
    Best Regards

Maybe you are looking for