473,326 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

If $ isn't allowed within a ImageButton.ID, why doesn't ASP.Net helps me with this?

Dear all

I've found a problem with raising server-events from a LinkButton (although I suspect that other Controls have the same problem). It appears that if you set the ID property with a string containing "$" that the Server-Side events aren't fired. This is probably caused by the fact that the Javascript __doPostBack expects the $-sign to be used for some Control-identification magic. Now if this is the case I would expect ASP.Net to either raise an exception when I try to set the ID with such an invalid character, or do some kind of escaping to make sure it works transparantly for me. Below the code behind for a WebForm with which I've tested this. The aspx only contains a Panel named MyPanel. Does anyone know if this is something I could have known

using System
using System.Collections
using System.ComponentModel
using System.Data
using System.Drawing
using System.Web
using System.Web.SessionState
using System.Web.UI
using System.Web.UI.WebControls
using System.Web.UI.HtmlControls

namespace LinkButtonTes

public class WebForm1 : System.Web.UI.Pag

protected Panel MyPanel

private void Page_Load(object sender, System.EventArgs e

LinkButton lb = new LinkButton()
lb.ID = "_Edward$Test$X"
lb.Click += new EventHandler(lb_Click)
lb.Text = "CLICK which doesn't work"
MyPanel.Controls.Add(lb)

LiteralControl lc = new LiteralControl("<br/>")

MyPanel.Controls.Add(lc)

LinkButton lb2 = new LinkButton()
lb2.ID = "_EdwardTestX"
lb2.Click += new EventHandler(lb_Click)
lb2.Text = "CLICK which works"
MyPanel.Controls.Add(lb2)
#region Web Form Designer generated cod
!!!REMOVED for clarity!!
#endregio

private void lb_Click(object sender, EventArgs e

LiteralControl lc = new LiteralControl("<br/>Hello")
MyPanel.Controls.Add(lc)


Nov 18 '05 #1
1 1027
Hi Bin

I'm aware of the fact that the contents of the ID of an HTML-tag is bound by rules, however, I'm using an ASP.Net Server-Control here. Although it ultimately will become an HTML-control, it's a more abstract concept, and I have the opinion that it's up to the creator of the ServerControl to make sure that the ID-property is correct, either by documenting what the allowed characters are and generating an Exception if I don't confirm to that, or make sure that by the time it gets converted to an HTM-Id it is in a correct form.
Nov 18 '05 #2

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

Similar topics

4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
7
by: Sky | last post by:
What I have currently: I have a user control called mod_container.aspx that is basically two divs -- the top a toolbar, that expands/collapse the second div which can contain other...
2
by: Michael Ramey | last post by:
Howdy, I think I have a good question! I'm creating a usercontrol, and within this usercontrol, I'm dynamically creating controls (imagebuttons to be exact), that the user can click on which...
1
by: RicercatoreSbadato | last post by:
I've put an ImageButton control in a repeater. I've set the 'OnItemBound' event of the repeater. Why when I click on the ImageButton it doesn't work? What else I have to do ?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.