473,785 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Collecti ons
using System.Componen tModel
using System.Data
using System.Drawing
using System.Web
using System.Web.Sess ionState
using System.Web.UI
using System.Web.UI.W ebControls
using System.Web.UI.H tmlControls

namespace LinkButtonTes

public class WebForm1 : System.Web.UI.P ag

protected Panel MyPanel

private void Page_Load(objec t sender, System.EventArg s e

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

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

MyPanel.Control s.Add(lc)

LinkButton lb2 = new LinkButton()
lb2.ID = "_EdwardTes tX"
lb2.Click += new EventHandler(lb _Click)
lb2.Text = "CLICK which works"
MyPanel.Control s.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.Control s.Add(lc)


Nov 18 '05 #1
1 1045
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
4293
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 I know I need to call a function that will save data but I'm not sure exactly when to call this function. I've tried two ways and both seem to have 'gotcha's':
7
2342
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 modules/controls (eg a newsfeed, quick phonelist, login, etc.) But the controls end up too 'deep': it appears that it would be lighter/better if I could just enherit the uc_login.aspx directly off of the uc_container.aspx so that all modules have the same...
2
4230
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 will cause a postback to occur. My problem is, I can't seem to be able to get the handlers to work within the user control, to determine which control has been clicked, and what to do with it from there.
1
4831
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
9646
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
9484
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,...
1
10097
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
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
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
6742
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
5386
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...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.