Sharepoint basics and any useful resources? - c#

Sorry about having 3 questions in one but they are closely related and should be simple for someone familiar.
I'm used to coding Java/Obj C/PHP and am finding trying to modify a template somewhat annoying partly because it doesn't make sense but mostly I can't find resources.
I am editing a master template and have gotten the basics but some things still allude me.
With the ContentPlaceHolders, is there a way to use it more than once? Someone posted some code about how you can do this but it said I couldn't use code here.
Is there a way to modify these ContentPlaceHolders without using Sharepoint designer?
I thought using the SharePoint: tag would be a possible way around this, but I can't find any docos on the possible tags and what they do and where to use them.
Thanks for any help.

A ContentPlaceHolder in a master page only maps to one Content section in a page/page layout.
Yes, you can modify the contents of ContentPlaceHolder using code, building a control tree.
The SharePoint tag prefix is used to signify a different control namespace, but there is no sharepoint:placeholder
Maybe if you explain what you are trying to do, we might be able to advise you the best way.

Related

Locating heading text using CSS

I have some C# code which will verify the heading text on a web page, currently located via xpath as follows.
Assert.AreEqual("Permissions", driver.FindElement(By.XPath(".//*[#id='navigation']/li[6]/h3")).Text);
This, as I understand, will check the text found at the end of the XPath matches the word "Permissions".
The above currently works but I would rather use CSS locators. I hear its best not to use XPath if possible.
I'm new to website testing so am not yet familiar with all this, any help will be much appreciated.
Let me know if there is more you require than what is provided above or if you have any alternate suggestions to the method already used.
I may not fully understand what you are trying to do but since this has no answer after 7 hours i though i might at least mention that if you are trying to get the innerhtml of the header you can use Agile Html http://htmlagilitypack.codeplex.com/ its very easy to use. Might not be what you are looking for though.

Dummies guide to making dropzone.js work?

I'm trying to implement a drag-n-drop fileupload to my website and found a piece of java called Dropzone.js, it holds everything i need . . . i just have no idea of how to use it!
So far I've been programming only in razor ASP.NET (c#) / HTML / CSS, but so far no javascript / jquery.
It's razor webpages, so no mvc.
Due to my current lack of knowledge in java, i apologize in advance but i'm stuck !!
What i'd like to know is:
I'f i've understood things correct, i should not modify Dropzone.js directly, i should use it as a library and integrate it in my other scripts, e.g. in another .js file. Correct?
Any help in this will be greatly appreciated.
Kind regards,
Daniel A. Rischel
.. Edited as per requested.
Well, you're wrong somewhat. It might not be related to the question but please note these scripts are JavaScript and
java != javascript
Got the point? :) Please try to note this in future. Also, Java code cannot be added to these server-side language, because java itself is a language. You can use JavaScript or its library (jQuery) and create some plugins.
I'f i've understood things correct, i should not modify Dropzone.js directly, i should use it as a library and integrate it in my other scripts, e.g. in another .js file. Correct?
True, you need to link this plugin dropzone.js to the site using
<script href="/link/to/dropzone.js"></script>
Then you'll use this script on the whole of the page where it is linked.
And you should never edit the source code of a plugin, untill or unless you know what you're doing. Because you might mess up with the code.
I'd really like to see some source code examples of what a single file drag-n-drop fileupload form would look like. I've googled extensively but not found something i can use yet.
Did you try to read their documentations? They have a good code explaination on the default (main) page of their website too. And really it depends on just the way you style it. Its just a plugin, you will need to add your own CSS code to style the form. This plugin won't style the form for you, all it will do is to handle the upload events and get back with the result. So, which means that form creation and elements is all upto you!
If there is a dummies tutorial in making this work, i'd really like to be pointed in the right direction!
There is no perfect answer to provide you with, however I will provide you with some basics
http://www.javascriptoo.com/dropzone-js
https://stackoverflow.com/questions/tagged/dropzone.js?sort=newest&pageSize=15 (stackoverflow tag)
In the second link, you can go and see what are the very basic of the issues that are handled with what code. Easy methods will be hanlded by you! You'll need some guidance in just the hard jobs. Good luck for that!
My suggestion for you is to first undertand and learn jQuery, then learn how to make ajax calls. After that you'll know how to create and handle the events. The basic code will be
$('input[type=file]').change(function () { // change in value
// send the file via ajax
}
http://jquery.com
This method will be best as you will know what code you're using and what it will do. Using plugin is easy method then this one. But my preference is with the second one; creating your own plugin.

ASP.NET making a user controlled template with WebControls in them

I would like to make a system where my users can customize the look and feel of my webapp.
My goal is to give them an HTML editor and some predefined tags like [BUYBUTTON] and [PRODUCTLIST] they can use.
These tags should be replaced with actual ASCX controls so that they not only display the HTML output, but have any code-behind functionality.
A generic find and replace of text/html is easy, I can't wrap my head around how to make the controls embed into the template.
Can someone give me a little push in the right direction here? I will be doing this within a DNN module if it matters.
I would look at how DNN's XML Skin parser works.
I wasn't able to find any good tutorials but here is a link so you at least know what Im talking about.
Cheers.
I would suggest to look at the source code of announcement module, which is doing almost same thing that you want to do.
Only difference here is, announcement module is storing the template in settings, so you can have different layout templates for different modules on same page/portal.
Hope this will help you, happy coding

Reasons and benefits for using a literal in asp over html

I am fairly new to asp.net so this may seem like a stupid question, but:
I am attempting to modify a pre-exsiting help menu in a web-app.
In this menu the previous developer, just used three literals seperated by paragraphs and a button linking to a 100 page manual. (i know doesn't seem to be much help, hence why i was planning to update and fix this)
What i had in mind was setting something up like a menu that would link to the different section of the page when the title is clicked.
So something along these lines:
<h1>Menu Contents</h1>
<ol>
<li>section1</li>
<li>section2</li>
<li>etc</li>
</ol>
After the contents section i would have the first section with it's details.
What i am wondering is why would i use asp-literals over just sticking to html?
So basically i would like to know what are the benefits or reasons for using asp literals and i guess when is it that i should use them?
I've attempted to find the solution to this on my own, but the only related matters i have been able to find have to deal with people arguing whether literals or labels are the best option so it's not entirely helpful.
Any help or suggestions are greatly appreciated.
Thanks.
You generally use literals if you want to be able to control the text you display programmatically. Say your page has a way to edit the section titles of your manual, for instance. Or say your manual is in multiple languages and you want the user to be able to set her language and see the section titles displayed in that language.
In your case, by what you're saying, I infer none of this applies and your manual is quite static. In that case I would stick to simple HTML.
Maybe it's been done that way so it would allow the links to be built dynamically, something like:
litMenuItem1.Text = "section1";
thus giving full control over the output? There are better ways to do that however.

Generate page dynamically & insert body into another page - is this realistic?

I have the requirement to create a page which contains a graph at the top, and for each item in the graph there's a fact sheet below. I already produce the fact sheets as stand-alone pages. Now, rather than recreating the fact sheet to include in the page I have to create, I'd like to use the work that already exists.
Is it realistic that I dynamically generate each fact sheet as needed, strip out the body and insert that into the new page? If so, does anyone have any pointers or suggestions? Thanks
I would suggest moving the content of the existing page into an ASCX user control - it should be a fairly quick job, and then you can incorporate it into other pages as required.
A quick way to implement this feature would be to use an iframe to load the other pages in to. This would allow you to keep using the work that already exists. Not the most elegant solution but it would work.
Hope this helps.
No, generating stuff you don't need and then removing it is inelegant at best, hackish, and will likely contribute to lowering the quality (including reliability, security etc.) of your code.
Refactor your factsheet page code to generate a header, but use a self-contained class/widget to generate the actual factsheet content. Then just instanciate and use that same class/widget on the other page as well.

Categories

Resources