Need help in creating Scheduling Control in ASP.NET - asp.net

I need to create a scheduling control in ASP.NET. Meeting slots are fixed to 30 minutes.
I am showing the slots in tabular format.
My main concern is to DateTime and slot timing like 4 to 4 4:30 to be read in code when user clicks particular cell in table, using HtmlTable control.
Table is created dynamically. Unfortunately the TableCell control don't have a click event.
In short, how can I detect the DateTime and timing from cell in the table by?

If you don't mind paying for a component, I'd save yourself lots of bother and just use DayPilot Pro. Or if you want open source, DayPilot Lite.

To acheive what you are suggesting you could add a button control to each cell as you are dynamically creating them. You will need to add the event to the button as you are adding them. As you want the slot time I would suggest using the command click event and assigning the specific slot time to the command argument property of the button control.

Not free, but a great control is Telerik's RadScheduler: http://demos.telerik.com/aspnet-ajax/scheduler/examples/overview/defaultcs.aspx

Related

Appropriate ASP.NET control to display detailed information of a record

This is a example of what I am trying to archive
(source: http://store.apple.com/us/product/H7537LL/A/)
I need to display data (mostly text, also have picture and files) from database to a webpage (this could be a product information or a job description or something like that...), what the the appropriate control that developer often use I can use to archive this.
When inserting text (multi-lines) from a textbox to database table, HTML is not allowed so when I pull data out to display them again to the webpage, the break line characters were lost all I get is bunch of text without line break.
I am having a hard time to find the way to save and retrieve, display data, any advices or comments are appreciated.
As per your requirement you can use asp.net Repeater control
Please refer this LINK for more detail about Repeater control
The Repeater control is useful if you need a high degree of control over the generated HTML. Also see the DetailsView control. Here is MSDN documentation describing these controls.
Repeater
The Repeater control is a data-bound container control that produces a
list of individual items. You define the layout of individual items on
a web page using templates. When the page runs, the control repeats
the layout for each item in the data source. For information about
programming the Repeater control, see Repeater Class in the MSDN
library.
DetailsView
The DetailsView control gives you the ability to display, edit,
insert, or delete a single record at a time from its associated data
source. The DetailsView control displays only a single data record at
a time, even if its data source exposes multiple records. For
information about programming the DetailsView control, see DetailsView
Class in the MSDN library.
I'm adding a second answer based on your edited question.
The page like the Apple one you linked to (if it were written in ASP.NET) would be comprised of many different controls, so there isn't any one control that's going to work well for this situation. You're going to end up needing to create an entire page. For that, the only suggestion is to study basic ASP.NET Web Forms to create your page, then load the production information based on the product specified in the URL.

ASP.Net, how to put hyperlinks in datagrids.

Hi i have a datagrid I've put in on a aspx web form in visual studio 2010, I'm new to this so I've been following the ms tutorials.
One of the columns on my data grid contains a lot of information, is there a way i can add a "+more" option in the cell next to the entry that shows only the first few characters of that cell, but once clicked opens all the information on that particular entry but onto a new aspx form?
Thanks for any help!!
There are basically three different ways...
Structure your data object/query so that it returns a key and and abbreviation (i.e, first name, last name, id, bio) and use a template that turns id into a link.
Use the onrowbound event to manipulate the controls on the row, so that you have a href to your details page.
Use css to show the additional info on a hover/mouse over (I like this, but it doesn't play well with mobile devices, which don't have either event).
EDIT: Methods 1&3 would be done on your aspx page, method 2 would be done in the codebehind for your page. Method 1 is really dependent upon your being able to control the data object/ query results. If you are calling a stored proc that someone else controls, it may be very difficult to make it work.

Create dynamic button with dynamic text

I have a project where I need to create menu buttons from a list in SQL Server. The problem I am having is that I need to add code to the text of those buttons. So there would be a birthday button and it should display the number of birthdays within the next two weeks or a button with the number of upcoming events. Any thoughts on how best to do this? Thanks.
Wade
Clarification:
There is no code yet, just some requirements. What I am doing is querying a table to get the list of buttons to display. Now each of these buttons may have dynamic text, for things like count of birthdays, events,etc... I am trying to see what the best way would be to handle this. Should I embed a snippet of code to go along with the menu item to execute when I iterate over the menu items? Maybe I should build a javascript file to go along with the code, which I add code to query a service for certain menu items? Thanks for any help.
what you are asking is close to impossible. Your requirement would be of dynamic coding, ie. the page knows nothing about event handlers before its compilation.
While you can add buttons dynamically, adding code dynamically (under the form of methods) is extremely difficult and represents a potential security hole!!
I said it's close to impossible, but not impossible yet, if you have lots of time to spend.
First: generating those buttons dynamically. Have you ever heard of Repeater control? I hope so, it allows you to add a button for each element returned by your SQL query. Obviously, you can grab text from the database (do you want to make it localizable? Additional effort is required for that)
Now what? You have to assign a custom behaviour to each of the buttons, and here comes the almost-impossible part.
Idea 1: use reflection and plugin components
"Simply" store in the database the strong name of a class that implements a known method with Action delegate, or Action<object> if you need a parameter, and have ASP.NET call that method when the button is pressed by analysing CommandName and CommandArgument of Button's Command event. Plugins can be stored (that's why you need strong name) inside separate DLLs in the Bin directory, with the possibility to hot-deploy new DLLs
Idea 2: scripting
Use a scripting language like Lua, and store a column about the script to run inside the database. When the button is pressed, run that script through Lua interpreter for C# (if you need the link to it and you are too lazy to do, I can Google around for you). This costs you lots of cross-integration between Lua and .NET, if it's worth the effort
No other ideas yet
If i understand you correctly, you don't have problems with creating the buttons but with their dynamic Text? You should do that in SQL. Are you using SQL-Server?
Something like this:
SELECT COUNT(*) AS Next2WeeksBirthDays FROM TblUser WHERE BirthDay < DATEADD(week, 2, GETDATE())
or
SELECT COUNT(*) AS Next2WeeksEvents FROM TblEvents WHERE TimeStamp < DATEADD(week, 2, GETDATE())
How about using a generic handler, that returns an image, that you manually create there? Use some of the System.Drawing classes to create your image (e.g. load small icons and write text) and simply write its byte[] to the OutputStream.
I'm trying to understand what you're asking here, so let me know if this doesn't answer your question. If you just want to run some logic against the items in your data source before you show them on the page, then the code is fairly simple:
ASPX page:
<asp:Repeater ID="Repeater1" OnItemDataBound="Repeater1_ItemDataBound" runat="server">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" />
</ItemTemplate>
</asp:Repeater>
C# Codebehind:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Button buttonCtrl = (Button)e.Item.FindControl("Button1");
string buttonText = GetButtonText(e.Item.DataItem);
buttonCtrl.Text = buttonText;
}
...where GetButtonText is a custom method that decides what the text of Button1 should be, based on the data row or list item being passed in.
If what you need is more complicated than that, respond below and I'll offer a different solution.
EDIT: What about just a library of Web User Controls that can be dynamically added to the page? There'd be no need to store any code in the database that way, just an indicator of which control to use and any parameters to pass in. Many CMS's operate this way.

collecting data from checkboxlist

Pretty basic question, I have a checkboxlist inside of a wizard control. I need to collect the value of all items that are checked, as well as whatever value is inside of a textbox if "other" is checked, to insert into my database during the Wizard.FinishButtonClick event. How do I do this? I need this in VB, please.
We cannot give you complete code to implement the task you want to implement, but can provide some starting point. Please go through the articles given below. Get back to us if you still have problems in implementing what you want after reading these.
Wizard control in .net
Asp.net and Vb.net wizard
Wizard control
I found all these in a simple google search.

Can database fields be dragged and dropped (as textboxes, not a gridview) into an ASP.Net form?

In VisualStudio, when you drag and drop a table or an individual column from a data connection in server explorer, a gridview is created.
What I want to be able to do is drag and drop the columns to make a quick and dirty detail form to display an individual record. Is this possible in any way?
An even better way to do this would be via a custom T4 or LLBLGen template but I have no clue how to do this.
Any other suggested approaches?
UPDATE: A DetailsView is the type of thing I am looking for, in that you can select a data source and the specific columns you want, but I'd like to be able to have manual control of the layout and formatting after the initial drag and drop.
I suggest binding a DetailsView to the table using a data source (SqlDataSource) instead. You might find these tutorials, especially this one helpful.
In response to your update, have a look at the FormView control. It gives you complete control of the layout using templated sections.
There appears to be literally no way to do this in VS that I have come across.

Resources