custom-server-controls

ASP.net weekly schedule control

半世苍凉 提交于 2019-12-06 04:23:35
Can anyone recommend a free asp.net control that I can use for the following: Weekdays Monday-Saturday along the top row Time of day along left hand side Template fields for the actual data Databindable Cells span the rows based on the start time and end time Here is a control that I found that is pretty good, but I am trying to find alternatives: Databound Schedule controls DayPilot is a pretty good general purpose calendaring/schedule control. The full version is not free, but there is a "lite" version available which is not only free but open source! 来源: https://stackoverflow.com/questions

How Do I Change the render behavior of my custom control from being a span

你离开我真会死。 提交于 2019-12-05 20:44:29
问题 When writing a custom control it always rendered as an HTML span element. How can I change it for example to a div? 回答1: Derive your control from WebControl as follows: public class MyCustomControl : WebControl { public MyCustomControl() : base(HtmlTextWriterTag.Div) {} } That is, use the base class constructor that accepts the tag to use. 回答2: If you derive from CompositeControl there is no constructor that takes a tag type. You can override TagKey (I haven't tried it), but a more flexible

ASP.NET Server Control - How to add AssemblyInfo file

别来无恙 提交于 2019-12-05 02:06:25
I've noticed on a few tutorials online that when a new ASP.NET Server Control is added, it automatically includes Properties folder (containing AssemblyInfo.cs) and a References folder. This works fine for me when creating a C# Server Control, but in VB.NET I just get a template .vb file and a Project file. Why is this and how can I get an AssemblyInfo.vb file? AssemblyInfo.vb file is created for every project. By default it is not displayed in the Solution/Project Explorer. To view this file and others in Visual Studio click Project >> Show All Files menu items. 来源: https://stackoverflow.com

Custom TextBox with built-in Validator: server side validation not firing

家住魔仙堡 提交于 2019-12-04 21:14:37
I have a class that looks like this: public class TextField : TextBox { public bool Required { get; set; } RequiredFieldValidator _validator; protected override void CreateChildControls() { base.CreateChildControls(); _validator = new RequiredFieldValidator(); _validator.ControlToValidate = this.ID; if(Required) Controls.Add(_validator); } public override void Render(HtmlTextWriter tw) { base.Render(tw); if(Required) _validator.RenderControl(tw); } } This has been working for a while in a internal application where javascript is always enabled. I recently noticed that an upstream javascript

How to persist List<T> property in ASP.NET Custom Control?

懵懂的女人 提交于 2019-12-04 06:37:25
I have the following property in a custom control: List<myClass> _items; public List<myClass> Items{ get { return _items; } set { _items= value; } } In my codebehind, I add items to the collection as in... myCustomControl.items.Add(new myClass()); However, these are not persisted across postbacks. What is the proper way to allow persistance in custom controls? Yikes! Don't put a List<> into the ViewState! It'll be massive! If you add a List<string> that contains two elements - "abc" and "xyz" into the ViewState, it'll grow by 312 bytes. If instead you add a string[] that contains the same two

How Do I Change the render behavior of my custom control from being a span

喜夏-厌秋 提交于 2019-12-04 03:32:04
When writing a custom control it always rendered as an HTML span element. How can I change it for example to a div? Derive your control from WebControl as follows: public class MyCustomControl : WebControl { public MyCustomControl() : base(HtmlTextWriterTag.Div) {} } That is, use the base class constructor that accepts the tag to use. If you derive from CompositeControl there is no constructor that takes a tag type. You can override TagKey (I haven't tried it), but a more flexible option is to override the RenderBeginTag method and make it do what you want. The base class renders a "span"

ASP.NET Custom Controls

荒凉一梦 提交于 2019-12-04 01:51:06
问题 How do you create a custom control (not an ASCX control) and, more importantly, use it in your project? I'd prefer not to create a separate project for it or compile it as a DLL 回答1: Server controls should be compiled into a DLL. There should be no reason to be afraid of having an additional assembly in your project, and it helps create good project organization. ASP.NET Server controls are actually custom classes in an assembly. They do not have an "ascx" markup file associated to them. To

How To: Use AJAX in an ASP.NET Custom Server Control

半腔热情 提交于 2019-12-03 03:47:07
Does anyone know of a good tutorial that demonstrates using an existing AJAX control extender in a Custom ASP.NET Server Control? I do not want to build a "Custom AJAX Server Control". I want to build a Custom Server Control that uses an existing AJAX control extender. I would like to combine an asp:TextBox, asp:ImageButton, asp:CustomValidator (with client side javascript from an embedded resource), and an ajax:CalendarExtender into one custom server control. Or has this already been created? Any help would be greatly appreciated. Thanks. UPDATE: Basically, I would like to create a

ASP.NET inject javascript in user control nested in update panel

十年热恋 提交于 2019-12-03 03:40:13
I'm trying to load javascript code with a user web control into a page via a the Page.LoadControl method during an asyncron post back of an update panel. I've tried the specially for that scenario designed methods of the scriptmanager, but the javascript just doens't get returned to the user. To explain my scenario a bit better: Master Page has the script manager and one page loads the user control via Page.LoadControl-method during an async post back. The custom control injects in the pre-render event handler the javascript. Is that a matter of timing to inject the js or is it just not

HTML 'name' attribute generated for ASP.net child controls, instead of the unique 'ID' attribute

有些话、适合烂在心里 提交于 2019-12-02 04:35:12
The generated HTML code for my custom ASP.net server control generates the name attribute for child controls, instead of the id attribute. Something like this : <span id="GridView2_ctl02_editdis"> <input type="text" name="GridView2$ctl02$editdis$ctl00"/> </span> The ID for the custom control itself is apparently proper. What is even stranger for me, is that the ID does get generated sometimes (I do not know under what conditions). But a FindControl() with that ID returns null on the server side. FindControl() with the value of the name attribute works just fine. Something like this : <span