Update Website Text that needs to contain Dynamic Data / Controls - c#

I am currently in the process of re-creating our schools website, as it's predecessor was quite painful to navigate / maintain.
We currently have an MS SQL Server with all of the data needed for the dynamic stuff.
My main issue is that ALL the website text needs to be editable by management, but in the middle of the text there may be a custom control (or dynamic data but that is not my issue). I was originally thinking of allowing a place holder and then having the server scan the text and replacing it with a web user control, however this has proved to be very difficult and probably bad practice.
I have spent almost a day searching Google attempting to find a solution but have had no luck with anything I have found.

One idea is to solve it with place holder syntax where you define a placeholder in the content that you can replace on the server.
One option is nustache https://github.com/jdiamond/Nustache
It will let you specify place holders like this: {{FirstName}}

Related

Connecting To A Website To Look Up A Word(Compiling Mass Data/Webcrawler)

I am currently developing a Word-Completion application in C# and after getting the UI up and running, keyboard hooks set, and other things of that nature, I came to the realization that I need a WordList. The only issue is, I cant seem to find one with the appropriate information. I also don't want to spend an entire week formatting and gathering a WordList by hand.
The information I want is something like "TheWord, The definition, verb/etc."
So, it hit me. Why not download a basic word list with nothing but words(Already did this; there are about 109,523 words), write a program that iterates through every word, connects to the internet, retrieves the data(definition etc) from some arbitrary site, and creates XML data from said information. It could be 100% automated, and I would only have to wait for maybe an hour depending on my internet connection speed.
This however, brought me to a few questions.
How should I connect to a site to look up these words? << This my actual question.
How would I read this information from the website?
Would I piss off my ISP or the website for that matter?
Is this a really bad idea? Lol.
How do you guys think I should go about this?
EDIT
Someone noticed that Dictionary.com uses the word as a suffix in the url. This will make it easy to iterate through the word file. I also see that the webpage is stored in XHTML(Or maybe just HTML). Here is the source for the Word "Cat". http://pastebin.com/hjZj6AC1
For what you marked as your actual question - you just need to download the data from the website and find what you need.
A great tool for this is CsQuery which allows you to use jquery selectors.
You could do something like this:
var dom = CQ.CreateFromUrl("http://www.jquery.com");
string definition = dom.Select(".definitionDiv").Text();

ASP.NET MVC Selectable Tree/Grid/Search Data View

I'm working on a web app in ASP.NET MVC 3 using the Razor HTML 5 engine and C#. The client wants something pretty complex and I would like to know if there is any examples out on the web that might show me how to begin setting this up. Here's what they are looking for:
I have a very large SQL database (25,000 rows). They want to be able to select the data using three different views on the same page.
The first will be a tree and using similarities in certain columns of the table will be how the tree is broken in to sections.
The second will be a grid. This will be just one entire list of the everything in the database that you can scroll through. Of course there has to be some sort of virtual scrolling because loading 25,000 rows rather quickly isn't going to happen.
The third will be a search box where you can type in the code and select it that way.
All three of these need to be linked so that when you type a code in the search box it will select it in the grid and in the tree. If you select it in the tree then it will be selected in the grid, and if you select it in the grid then it will be selected in the tree.
They also want me to remember the last selection when you navigate away and be able to type a code n on a different page and go directly to this page with the item you typed selected. Therefore, I need to be able to use MVC's capabilities to establish a hyper link for every item in the list (I assume that would be the way to do this)
This is honestly the first time I've worked with ASP.net MVC and I feel like I may have bitten off more than I can chew with this project so any help would be greatly appreciated!
They would rather it if I didn't need to include any extra dll's so if there is a way to do this without third party tools that would be even better, but at this point I'm just looking for anything.
A few random ideas/thoughts about this:
This is kind of a big project as your first MVC app - hopefully you have some experience with HTML/Javascript/jQuery since it's going to require a fair amount of glue code to make everything work together. There is no "here, do this" solution.
There are a bunch of different free/open source projects for treeviews and grids. I've used jqGrid for a number of projects - it works well. It has a decent API and is fairly configurable (although it may take some digging to find the example code you need).
For a treeview, you can try jsTree. I haven't worked with it, though.
I'd suggest starting with just the treeview, or just the grid and get it working first. Then add the other control and get it working. Then add the search. Finally, I'd work on getting everything to work together.
To handle navigating to a specific selection, you can pull information off the query string from Javascript.
Realize that most of this is going to be happening in Javascript on the client side, not much server side.

Storing variable number of items in a database

I am using ASP.NET and Razor to create a calendar application similar to Google calendar and was hoping to get some feedback on my design thus far. My idea is to have 2 tables, one normal table for users, and another for a table of events which will store the users id and the time of the event, event ID, name of the event, and duration of the event.
I plan to write some code that will display a calendar on screen and allow the user to select multiple times so as to mark them as busy and give them a name. When this is done, the user submits the information and it is inserted into the database.
What is the best way to go about tackling this calendar construct? I can't really think of a simple way. I am guessing I can create a nice looking calendar using HTML and CSS, and perhaps JS to allow the drag and drop functionality? I suppose when the user selects a time, an object would be created with a start time and default duration, then when they drag it the duration changes. I am confused by how you would do this however, pulling objects out of thin air. How does Google Calendar do this?
And then how do you store all of the created objects in the database? I am guessing that Razor has a foreach construct and that I could just iterate over all objects created and insert them into the database one-by-one?
Also, how could I clean up the database, garbage collecting events that have already transpired while keeping events that are constant ie daily/weekly?
Apologies if the question is vague, if it is too vague then please press me on details I can be more clear on rather than close this. Thank you.
What is the best way to go about tackling this calendar construct?
If you are wondering about data structure here, whatever you do, do it in that way that it makes it compatible with standard iCalendar standard
I can't really think of a simple way.
Calendars are quite complex applications, there is no simple way. (events, sharing events, tentative, attendants, reminders...)
I am guessing I can create a nice looking calendar using HTML and CSS, and perhaps JS to allow the drag and drop functionality?
Yes.
I suppose when the user selects a time, an object would be created with a start time and default duration, then when they drag it the duration changes. I am confused by how you would do this however, pulling objects out of thin air. How does Google Calendar do this?
You can find some existing jquery plugins for this (try with this for start, or take a look at this list).
And then how do you store all of the created objects in the database? I am guessing that Razor has a foreach construct and that I could just iterate over all objects created and insert them into the database one-by-one?
Check out these jquery plugins and see how do they communicate with the server side. You will end up making ajax requests and then making database queries in the database. Razor has nothing to do with database...also Razor has nothing to do with client side interaction, it just renders page and everything else is on the js side.
Also, how could I clean up the database, garbage collecting events that have already transpired while keeping events that are constant ie daily/weekly?
I would't delete anything from database...don't see a reason for that. Just grab all you have and fill in the calendar. User will always look at month/date/week...grab data for that period and show it. When he goes back one year, he will have all the data still available.
Have you met my friend, Google?
In particular, 4GuysFromRolla has a tutorial, and there is a nice looking open source calendar control with some tutorials that should get you well on your way.

Content Editor for Client

I've created a website for a client of mine. It is coded in ASP.NET with C# and hosted on GoDaddy. She requires this website to updated daily by her. However, this client has very little knowledge of how to edit HTML or text within a site. I don't want to edit it every time she wants an update on the site.
What would be the best solution to my problem? I have looked up Content Management Systems, but I'm a little confused by what exactly it does in terms of coding and the management of the existing site. Does it require me to reformat the whole site to follow the CMS's 'templates'? Would it be better for me design my own back-end panel for her to edit the content (this would obviously take significant work)?
If you want to stick with a site you're developing from scratch, I'd use the HtmlEditor from the AjaxControlToolkit or a similar control, and store the html content in the database.
Then, when outputting the html from the database to the client pages, I'd make sure to use the Microsoft Anti-Cross Site Scripting Library to sanitize the html using the GetHtmlFragment() function (since this is tagged asp.net). It's not that much work, actually, if you design the database correctly, and if you've got the skills.
CMS systems are (trying not to oversimplify) entire web sites that are already built and allow people to edit the content using built-in content editing functionality. They range in functionality and extensibility from a "You get what you get and there's very little you can change" to "You can customize the heck out of it and buy or build your own modules to extend functionality." There are a lot of good ones out there, some free, and some expensive.

Custom PropertyGridEditor etc. for web part edit zone?

I want to change the appearance of the default editor parts, and am a little unsure of how to go about doing this, as there seems to be a surprising lack of documentation on the subject.
I've been able to create a custom declarative catalog with some trial and error and overriding the RenderCatalogPart method, and now wish to do something similar with my AppearanceEditor and PropertyGridEditor. I've tried just changing the style of the editor parts using CSS, but they are already arranged into tables which are impossible to get rid of. It's not even possible to just take the class as is, because the classes are sealed. So I'm basically stuck with having to write my own from scratch, I guess the questions are as follows:
1) How do I go about getting the information on the controls I need to render?
2) According to the documentation, I need to override the ApplyChagnes and SyncChanges methods - but I can't find any information on what I actually need to put in these methods.
3) On a similar note, is it possible to change the layout of the EditorPart itself, so that the AppearanceEditor, BehaviourEditor etc. are displayed side-by-side instead of on top of eachother?
4) Is there any way to have the page catalog displayed somewhere on the page, even in browse mode? I'd quite like to use it as a 'minimised' area, where users can send web parts they don't want immediately. At the moment they go back into the page catalog and users tend to just add a new part instead. I know that I can have multiple catalog zones on the page, which is great, but it only shows up in catalog mode.
Any help would be very much appreciated.
I didn't get any replies here, but I was able to figure out a way to do some of these.
In the end I decided to use reflection to get each public property on the web part that was WebBrowsable, and figure out what sort of control to display from the type.
The ApplyChanges() and SyncChanges() methods essentially just persist the changes from the page to the personalization blob and vice-versa. It's a matter of rendering some controls on the page, and mapping the values to the properties of the web part in these methods.
I don't think this is possible without writing your own.
Haven't been able to do this, but I don't imagine that it's possible sadly.

Categories

Resources