I'm working on asp.net (web application). I have to use time picker control in my page. Hence i downloaded 'time picker.dll' file from some website. I need to integrate this 'dll' file into my project. can anyone pls guide me in the same?
You would add it as a reference in the project. Right click on VS and add reference and browse to it.
In your file include a using statement for the namespace of the DLL and then you should be able to instantiate a new object.
Copy the "time picker.dll" into the Bin folder of your web-app and add <%#Register %> directive into your web-page to use that control.
Assuming dll package the typical ASP.NET server control, you have to add reference to the dll (VS Studio Project -> References -> Right-Click & Add Reference, Browse the dll file).
Next thing to do is to add the control on tool box by right clicking on the toolbox and selecting the control. Now you can drag the control on the ASP.NET Design surface. Alternatively, you can use the object browser to check the control name and use the register directive.
Related
I have Java background and am trying to start on C#.
I wanna create a lib in C# that will be used in other solutions. In Eclipse it's just a matter of creating a jar and adding it to classpath. I know each project in VS2013 becomes a dll, but how can I make a solution see these dll?
Also, in Eclipse, we can create a Web Fragment Project. It can have Servlets, jsp and static js and css files, it becomes a war file and can be imported into another project and its files be used in that project.
How can I do that in VS2013? I'd like to create a solution with static files, master page, some aspx stuff, C# dll, and then use them all in other solutions.
Is there any tutorial (I googled it but found nothing) teaching how to do it?
You have a few options depending on your preferences and scope
Option 1 - The Class Library
You can create Class Library, that can be referenced in your website project. The Class library is a library of classes, interfaces, and value types
You can either Add an existing/New Class Library project to your website solution and reference it directly
You can add the project to your solution by right clicking the
solution (inside VS) -> Add -> Existing project -> and navigating to said
project's .csproj file
or
You can use a new/existing Class Library Project - build it and reference the built dll in your website solution.
you can right click your website solution (inside VS) -> Add -> new project -> choose Class Library
After you've done one of the above ->
Right click the project, you want to add the reference to
Click "Add Reference"
navigate to the .dll in question.
If the dll you want to reference is part of your current solution (as in step 1) -> after you've pressed "Add Reference" - press the "Solution" Tab and it should show up
After you've added the dll.
Remember to reference it in your code files with
Using TheReferenceNamespace;
which will allow you to call the functions inside you dll like the following
FunctionInsideDll(param);
or you could fully qualify your calls instead, like the following
TheReferenceNamespace.FunctionInsideDll(param);
Option 2 - Share MasterPages
if you just want "shareable" masterpages
you can do the following - (taken from this -> MSDN article)
(for future reference - web archive link - just in case something gets moved)
Precompile the Code Used in a Master Page
If you are concerned about code in your master pages being visible to others reusing the pages, you can precompile the master pages' code into a library. In this library, you can include code-behind pages as well as user or custom controls. Compiling master pages does not remove the declarative code for the master files or any server controls used, but you can compile the master files to remove the code for controls or code-behind pages used by the master pages.
If you choose to compile the master pages into a library, you must use the "updatable" build option that allows for later modification of the markup. This option is determined by the Allow the precompiled site to be updatable check box in the Publish Web Site dialog box. For more information about precompiling pages into a library that can be reused, see Building Re-Usable ASP.NET User Control and Page Libraries with VS 2005.
Option 3 - The template
Create a template, and use that template for different projects
In Visual Studio - Press "File" -> Export Template -> follow the wizard.
After it has been exported and you've imported it (either through a checkmark in the wizard or double clicking the vsix file) -it will show up under your project templates when you create a new project.
You can include a project from solution A in solution B by right-clicking on solution B and choosing "Add existing project"
Don't be afraid to edit XML .csproj files. For instance, this works ...
<Compile Include="$(Codez)\z.Libraries\diff-match-patch\DiffMatchPatch\**\*.cs"
Exclude="NotThisOne.cs;**\NotThisFolderWith\This*.cs">
<Link>Libs\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
...and will give you all the C# files from the source folder, and subfolders, as linked files in your destination project under a folder called \Libs\.
$(Codez) is a Windows Environment Variable I use on my PCs.
I also could have used *.* at the end instead of *.cs.
This is one of those things Visual Studio might break on you, adding a file into the folder full of wildcard-linked files may break them out to separate entries. Or not. Depends on the wind.
I made a project in Name "Project1". Now I want to changed full project named "Project2".
All code working fine. But when I create SetUp then file name Shows "Project1". How I renamed this?
right click the project
go to properties
go to application tab
change the assembly name
You can also change the assembly information using the button on the same page if you would like everything to tie up
Try right-clicking the project and select Rename from the context menu.
I have some .dll and .xml(e.g. FarsiLibrary.Resources.dll ,FarsiLibrary.Resources.xml) to use with Persian calender .
how do I import it in my project.
note: I'm using Visual Studio 2012.
"Right click on project -> Add Reference -> Browse..." for DLL.
Add existing file for XML.
You just need to do following
Right click on your project and choose Add Reference.
When the dialog comes up, choose the Browse tab and go find your dll
After adding the assembly include that reference in your class or
form where ever you are going to use
Or you looking for [DllImport("dll")]? More Here
I'm trying to add/change images in my project, using Microsoft Visual Studio 2008 C#. Along with it, Devexpress components are also included.
What I did, I copied an image (.png file) and paste it it in my "PrintRibbonControllerResources.resx" and then after that I have to open again the MainForm.cs right click on the form and click on the Run Designer. It will open the Ribbon Control Designer. From there, I can add the image.
Do you think its ok? It's my first time to do this, and I don't have any experience & I'm learning it by doing.
Thanks
===
it seems I don't see the add function under resource tab
I generally add an image to the project itself. (Add/Existing item) I do this so I can use SourceControl to check in/out the image file. The resx then links to these files.
Basically, my philosophy is: if it works, don't fix it.
If this solution works for you, it's fine. At least, until you discover a situation where it fails.
If you go in the properties of your project, and select the resources tab, you can add it directly from there and it will be accessible in the default resource file of your project, which might be more convenient.
I like to add it to a solution folder (or folder in the project) and like that to the resx via "Add Exising File".
I get all of the advantages of having the resource file, but also the advantages of having a physical file (editing, quick view, etc.)
I am converting a 1.1 project to 2.0 and am having an issue with some User Controls.
In the original project, there was a class library project and the website project. In the class library project, there was a folder called UserControls and in this were several ascx files and their code behind files.
I'd like to keep the same structure so I bring in these user controls into my new solution in a separate class library project. I changed it from being a full class to a partial class and changed the CodeBehind to CodeFile of the page.
In the old user control, all the web controls in the User control were listed like follows
protected System.Web.UI.WebControls.DropDownList _findModeList;
etc.
I thought with it being .net 2 and using the CodeFile attribute instead, I may not need to do this but it doesn't compile when I omit it.
However, when I include it, it does compile, but I get "Object reference not set to an instance of an object." error when trying to use _findModeList in the code file.
Is it possible to put User Controls in a class library in .net 2.0 up?
Not really. The .ASCX file should be included in each Web Application project that uses it. To avoid duplicates you can store the UserControl in your Class Library's folder and use the "Add As Link" feature of Visual Studio.
Select "Add Existing Item" in your Web Application's context menu, select the user control and, instead of clicking the "Add" button, click the arrow in that button and select "Add As Link".
Are you working with a Web Application Project? Or a Web Site? It's confusing, I know...
If you are working with a WAP, use CodeFile and let ASP.NET generate the .designer.cs files for you. Do not declare the objects from your .acsx. You are declaring a new/different DropDownList when you explicitly declare _findModeList in the .cs file referenced by CodeFile. That is why you get the null reference... it has not been initialized. If you don't have a .designer file, right-click on the .ascx in Solution Explorer and click "Convert to Web Application".
If you are working with a Site rather than a WAP, use the CodeBehind attribute. It will continue to work like in ASP.NET 1.1 and compile on the fly.
To get a control to live entirely in a DLL... use "custom controls" rather than user controls. Again, confusing.
Actually you can try create new Web Application Project not Create new Web Site , because between these two are different project.
After you create Web Application just create your User Control (.ascx). After that you can try Rebuild your Web Application. After finished you can browse to your bin directory , there should be dll for your web application. Now you can use this dll in another website/web application project. Just add reference to this dll.
Have you tried changing/adding the Inherits attribute in the <%# Control %> tag?
<%# Control Language="C#" CodeBehind="<PathToTheFile>" Inherits="namespace.and.classname" %>