web-controls

Trouble with FindControl and dynamicly created controls

此生再无相见时 提交于 2019-12-10 15:54:52
问题 Example code: var div = new HtmlGenericControl("div"); div.Controls.Add(new Literal() { ID = "litSomeLit" }); var lit = (Literal)div.FindControl("litSomeLit"); Assert.IsNotNull(lit); This code fails the assert, because lit is null. Debugging shows that div.Controls definitely contains a literal with ID of "litSomeLit." My questions are "Why?" and "Is there any way to get a control of a specific ID without doing a recursive search of div.Controls[] by hand one element at a time?" The reason I

What’s wrong with use of “Using” block on Webcontrols?

岁酱吖の 提交于 2019-12-10 15:53:49
问题 I have following code that uses “ using ” block on TableHeaderCell , LiteralControl , HyperLink and GridViewRow ( try..finally ). The code is working as indented. Is there any issue/pitfall in disposing the controls with “using” block as shown below? If yes, can you provide any msdn reference that shows details of the pitfall? protected void grdTransactions_RowCreated(object sender, GridViewRowEventArgs e) { if (e != null) { if (e.Row.RowType == DataControlRowType.Header) { GridViewRow

default value in asp.net server control

拟墨画扇 提交于 2019-12-10 14:30:13
问题 I have a problem with the default value attribute. When I add my control to page at design mode, default value does not work. This is my code: [DefaultProperty("Text")] [ToolboxData("<{0}:KHTLabel runat=server key=dfd></{0}:KHTLabel>")] public class KHTLabel : Label ,IKHTBaseControl { [Bindable(true)] [Category("Appearance")] [DefaultValue("KHT")] [Localizable(true)] public string Key { get { String s = (String)ViewState["Key"]; return ((s == null) ? String.Empty : s); } set { ViewState["Key"

Required Property in Custom ASP .NET Control

大兔子大兔子 提交于 2019-12-10 09:28:02
问题 I am making a custom web control for my ASP page that inherits from CompositeDataBoundControl. I have a public property in the definition of my control that is required , if the user does not provide this property in the control definition on an ASP page it will break and we will get an exception. I want the compiler to throw a warning similar to the one when a user forgets to provide the 'runat' property of a Control. "Validation (ASP.Net): Element 'asp:Button' is missing required attribute

Is it possible to add a web user control to a class library?

人走茶凉 提交于 2019-12-10 02:54:21
问题 I'm looking at building some web user controls with an eye toward re-use, but I can't seem to add a Web User Control in my class library in VS2008. Is there a way to work around this problem, or is there a better approach to creating reusable controls? 回答1: You can create either Web User Controls or Web Custom Controls that encapsulate the functionality you need. The main difference between the two controls lies in ease of creation vs. ease of use at design time. You should maybe consider

Microsoft.Web.UI.WebControls Treeview not rendering on some machines

天大地大妈咪最大 提交于 2019-12-09 23:19:58
问题 We have a simple web page which displays a treeview ( Microsoft.Web.UI.WebControls ) Now, on some machines (mainly the clients ones ;-) ) the treeview isn't rendered properly : I've tested this on all my machines, even linux, and everything is rendered correctly here. I can reproduce this error though by removing or renaming the 'webctrl_client' folder. I don't understand however what this problem can be? The 'webctrl_client' folder is correctly installed in the root www folder, and the .dll

LINQ query to WebControl.Controls

匆匆过客 提交于 2019-12-08 06:32:35
问题 I have three TextBox controls on the page <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" OnTextChanged="TextBox_TextChanged" TabIndex="1"> <asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True" OnTextChanged="TextBox_TextChanged" TabIndex="2"> <asp:TextBox ID="TextBox3" runat="server" AutoPostBack="True" OnTextChanged="TextBox_TextChanged" TabIndex="3"> and an event handler protected void TextBox_TextChanged(object sender, EventArgs e) { WebControl changed_control =

ASP.NET Web Control for Progressing Bar

时光总嘲笑我的痴心妄想 提交于 2019-12-08 06:11:35
问题 I would like to know how can I create a simple progressing bar, that could show to a user a friendly look for a variable with values from 0 to 100%. This variable has been populated with a method in my code. Do you have any idea? Thanks for your time. I am using C# and asp.net 4 The idea is smt like this 回答1: You can use jquery plug in for this check the following links http://docs.jquery.com/UI/Progressbar jQuery.UI ProgressBar Widget 来源: https://stackoverflow.com/questions/4930815/asp-net

interacting with awesominum webcontrol

对着背影说爱祢 提交于 2019-12-08 04:11:08
问题 Can you find HTML elements in awesomium webcontrol to do the further processing? For example, I can find necessary element (or even element collection) in Watin using: Link playButton = myie.ElementOfType<Link>(Find.ById("myid")); // find link (<a>) Div test = myie.Div(Find.ById("audio")); // find div (<div>) When found - you can extract multiple properties of that element string classname = playButton.ClassName; // alternatively -> inner text, link, id, class and all bucket of other

MFC : How to capture a link click event in a web browser control?

两盒软妹~` 提交于 2019-12-08 01:06:25
问题 I have an MFC application that has a webcontrol. When clickable links are clicked, it opens using IE, not the default browser. Questions : Is there a way to force it to open using the default browser? If not, how do I capture the Link Click event so I could just manipulate the click event later? Thanks... 回答1: No, not as far as I know. Check out the articles on http://ehsanakhgari.org/article/visual-c/webbrowser-goodies . It has a number of articles that show how to set up an event sink using