473,698 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ParseControl()

Good morning. I am having a problem with the TemplateControl .ParseControl()
method. It does parse the string into a control; however, added attributes
are left out of the parsing and make it to the final HTML code. For
example:

ParseControl("< asp:button OnClick="Btn_Cl ick" text='Click here!'
runat='server' />");

Becomes this HTML:

<input type="submit" OnClick="Btn_Cl ick" />

I can somewhat see why this would happen, as onclick is an event of the
browser. However, I need ParseControl() to treat OnClick as the ASP.NET
event, not the browser's DOM. Any suggestions?
Nov 18 '05 #1
1 1920
You can always hook up the event manully through the event handler...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/webblog/
----------------------------------
Making waves on the Web
"Jeremy McPeak" <http://www.wdonline.co m/contact.aspx> wrote in message
news:Oy******** ******@TK2MSFTN GP12.phx.gbl...
Good morning. I am having a problem with the TemplateControl .ParseControl() method. It does parse the string into a control; however, added attributes are left out of the parsing and make it to the final HTML code. For
example:

ParseControl("< asp:button OnClick="Btn_Cl ick" text='Click here!'
runat='server' />");

Becomes this HTML:

<input type="submit" OnClick="Btn_Cl ick" />

I can somewhat see why this would happen, as onclick is an event of the
browser. However, I need ParseControl() to treat OnClick as the ASP.NET
event, not the browser's DOM. Any suggestions?

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2267
by: Matthias Lohrer | last post by:
Hi, I'm playing around with the possibilities of Page.ParseControl. Thanks to Kirk Allen Evans I got my example running (Posting Juli, 17, "Re: Generating ASP.NET-Controls with XSLT possible?"). But looking deeper I run into a problem: Kirk said, that "validation works as expected", but in my experience it works only to a certain degree "as expected".
0
3030
by: Matthias Lohrer | last post by:
Hi, I want to add dynamically controls to my aspx-Page by using the Page.parseControl-method. Page_Load contains this code: str = "<asp:TextBox runat='server' id='txtEingabe' TextMode='SingleLine' /><asp:RequiredFieldValidator id='req' runat='server' ControlToValidate='txtEingabe'>Bitte um eine
0
1187
by: Chris Simeone | last post by:
Hello, I'm having problems with the ParseControl() method creating unexpected output which I think is preventing events from firing. My code is based on this MSDN article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/ frlrfsystemwebuitemplatecontrolclassparsecontrolto pic.asp
2
1487
by: Chris Simeone | last post by:
When I use ParseControl in a C# code behind to create a button... Control c3 = ParseControl("<asp:button id='Button3' text='Btn3' oncommand='OnButton' commandname='Btn' commandargument='b3' runat='server' />"); The HTML that's rendered looks like this... <input type="submit" name="Button3" value="Btn3" id="Button3" oncommand="OnButton" />
1
1638
by: Jeremy McPeak | last post by:
I am playing around with ParseControl(), and I have a question. First here is the code I am using: Control MyButton1 = Page.ParseControl("<asp:button id='MyButton' text='Click here!' runat='server' />"); Form1.Controls.Add(MyButton1); This adds the button to the form; however, I cannot access the button using it's ID (and I have declared it in the class). I can, however, access it through the Controls collection of Form1. The...
0
1407
by: PB | last post by:
According to the documentation, ParseControl returns a parsed control from an input string. The documentation seems to assume that *one* control will be parsed from the string. My implementation will require an unknown number of controls (always at least one) to be parsed from the string... after which I inject the resulting HTML into a PlaceHolder control (see code below). In my testing, it appears that ParseControl will successfully...
0
1138
by: Fox | last post by:
Greetings, How can i parse inline code? I have the following code: System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<asp:TextBox id=\"myControl\" runat=\"server\" />"); sb.Append("<%= \"Hello!\"%>");
0
1281
by: Dave | last post by:
Hi, I have a very simple page where i am using Page.ParseControl to create a datagrid control. When i try to run the DataBind method i get various errors. The code for the datagrid is as follows and is fired on OnInit string grid = "<asp:DataGrid ID=\"grid2\" runat=\"server \"><Columns><asp:TemplateColumn><ItemTemplate><asp:LinkButton ID= \"link1\" runat=\"server\"><%# DataBinder.Eval(Container.DataItem,
1
1819
by: Jordan S. | last post by:
Using .NET 3.5, I'm wondering how to get a control's specific type (e.g,. "Button" and not simply "Control") after the control is inserted into a control hierarchy - when ParseControl is used. For example, I have the following code: string str = "<table border=1><tr><td>Hello World</td></tr><tr><td><asp:Button ID=\"TestButton\" onclick=\"b_Click\" runat=\"server\" Text=\"Button\" /></td></tr><tr><td>Goodbye...
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.