web-controls

define Custom Event for WebControl in asp.net

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 01:31:22
问题 I need to define 3 events in a Custom Control as OnChange , OnSave , and OnDelete . I have a GridView and work with its rows. Can you help me and show me this code? 回答1: Good article which can help you to achieve your task: Custom Controls in Visual C# .NET Step 1: Create the event handler in your control as below. public event SubmitClickedHandler SubmitClicked; // Add a protected method called OnSubmitClicked(). // You may use this in child classes instead of adding // event handlers.

How do I make my ASP.NET server control take an embedded code block as a property value?

拥有回忆 提交于 2019-11-30 07:24:35
I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so: <cc1:customControl runat="server" Title='<%= PagePropertyValue%>' > more content </cc1:customControl> When I do this, however, I am getting the exact String <%= PagePropertyValue%> being displayed rather than the Property Value that I would like to see. So after trying the databinding expression (as suggested below). I don't get the string literal that looked bad but I don't get anything else either. <cc1:customControl runat="server" Title='<%#

Webforms and jQuery, how to match the ID's?

自作多情 提交于 2019-11-30 06:59:52
I want to use jQuery with asp.net webfoms. Do I need to get a special toolkit so the .net controls spit out friendly Control ID's? Reason being, I don't want to write javascript referencing my html ID's like control_123_asdfcontrol_234. Has this been addressed in version 3.5? (I remember reading you have to get some special dll that makes ID's friendly). The easiest way I've found is just to match on the end of the mangled ID for most controls. The exceptions that Know of are radiobutton lists and checkbox lists - you have to be a little trickier with them. But if you have this in your .aspx

Using linq to get list of web controls of certain type in a web page

倖福魔咒の 提交于 2019-11-29 12:25:06
Is there a way to use linq to get a list of textboxes in a web page regardless of their position in the tree hierarchy or containers. So instead of looping through the ControlCollection of each container to find the textboxes, do the same thing in linq, maybe in a single linq statement? One technique I've seen is to create an extension method on ControlCollection that returns an IEnumerable ... something like this: public static IEnumerable<Control> FindAll(this ControlCollection collection) { foreach (Control item in collection) { yield return item; if (item.HasControls()) { foreach (var

How can I include additional markup within a 'Content' inner property of an ASP.Net WebControl?

与世无争的帅哥 提交于 2019-11-29 11:21:16
I've searched the site and I cannot find a solution for my problem, so apologies if it's already been answered (I'm sure someone must have asked this before). I have written a jQuery Popup window that I've packaged up as a WebControl and IScriptControl. The last step is to be able to write the markup within the tags of my control. I've used the InnerProperty attribute a few times, but only for including lists of strongly typed classes. Here's my property on the WebControl: [PersistenceMode(PersistenceMode.InnerProperty)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)

ASP.NET CheckBoxList DataBinding Question

纵饮孤独 提交于 2019-11-29 10:52:04
问题 Is it possible to DataBind an ASP.NET CheckBoxList such that a string value in the data becomes the label of the check box and a bool value checks/unchecks the box? On my asp.net webform I have a CheckBoxList like this: <asp:CheckBoxList runat="server" ID="chkListRoles" DataTextField="UserName" DataValueField="InRole" /> In the code behind I have this code: var usersInRole = new List<UserInRole> { new UserInRole { UserName = "Frank", InRole = false}, new UserInRole{UserName = "Linda", InRole

How do I make my ASP.NET server control take an embedded code block as a property value?

为君一笑 提交于 2019-11-29 10:25:11
问题 I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so: <cc1:customControl runat="server" Title='<%= PagePropertyValue%>' > more content </cc1:customControl> When I do this, however, I am getting the exact String <%= PagePropertyValue%> being displayed rather than the Property Value that I would like to see. So after trying the databinding expression (as suggested below). I don't get the string literal

Fluent interface for rendering HTML

江枫思渺然 提交于 2019-11-29 08:40:32
问题 Rendering HTML with the HtmlTextWriter isn't incredibly intuitive in my opinion, but if you're implementing web controls in web forms it's what you have to work with. I thought that it might be possible to create a fluent interface for this that reads a bit more like the HTML it outputs. I would like to know what people think of the syntax that I've come up with so far. public void Render(HtmlTextWriter writer) { writer .Tag(HtmlTextWriterTag.Div, e => e[HtmlTextWriterAttribute.Id, "id"]

Multi-select dropdown list in ASP.NET

痴心易碎 提交于 2019-11-26 18:45:54
Do any good multi-select dropdownlist with checkboxes (webcontrol) exist for asp.net? Thanks a lot You could use the System.Web.UI.WebControls.CheckBoxList control or use the System.Web.UI.WebControls.ListBox control with the SelectionMode property set to Multiple . Aleris jQuery Dropdown Check List can be used to transform a regular multiple select html element into a dropdown checkbox list, it works on client so can be used with any server side technology: (source: googlecode.com ) Try this server control which inherits directly from CheckBoxList (free, open source): http:/

Multi-select dropdown list in ASP.NET

百般思念 提交于 2019-11-26 06:35:21
问题 Do any good multi-select dropdownlist with checkboxes (webcontrol) exist for asp.net? Thanks a lot 回答1: You could use the System.Web.UI.WebControls.CheckBoxList control or use the System.Web.UI.WebControls.ListBox control with the SelectionMode property set to Multiple . 回答2: jQuery Dropdown Check List can be used to transform a regular multiple select html element into a dropdown checkbox list, it works on client so can be used with any server side technology: (source: googlecode.com) 回答3: