473,734 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the server-adjusted ID of a repeated user control

Hi,

Outline of problem:

I've built a set of user controls that are used to output questions for a
survey and gather the responses using simple radio buttons.

I'm adding an optional textbox to the question control to allow individual
typed responses per question. I've got a maximum length to enforce which
matches the underlying data table design.

When asp.Net outputs a textbox set to multiline mode, the server actually
outputs a textarea tag. Fine, but I've found that the MaxLength property
seems to get ignored. I have previously got around this by providing a
javascript function to update a display of the characters remaining and
adding an Attribute to the specific textbox when the page loads that fires
the javascript function on the "onkeyup" event.

The javascript is straight-forward enough and the function allows a pair of
object names to be passed in, which correspond to the text entry textbox and
the chars remaining display textbox.

The issue I am having a problem with is that due to the question control
being repeated multiple times down the page, the server also adds a custom
prefix to each element ID that extends the original ID, so when I need to
add the attribute, I also need to know the adjusted ID of the specific
instance of the textbox.

Example output steps:

1. Out put header label values
2. Start outer loop to output question block header
3. Step 2 makes call to a second loop that outputs questions for the block

For example, the original ID of "txtResText " might become
"ctl109_txtResT ext", with the "ctl109_" bit varying according to how many
instances of the textbox there are. This is complicated a little as the
question control is not the only control being added to the page. There are
a set number of "static" controls that are output from the database. This
is important as it makes the starting number of the prefix higher than a
simple zero-indexed count of the question control on its own.

Say I have three "normal" labels populated before the repeated controls are
reached. These controls ID's remain unaffected, but they make the prefix of
the repeated control ID's start at "ctl104_".
My proposed solution:

I could use this knowledge to create a counter (with an offset to accomodate
the non-looped controls) that increments along with the output loops of the
various user controls, but this seems like a "hammer to crack a nut"
approach. Also, If I ever wanted to add further output prior to the loops
starting, I would have to remember to adjust the offset of the counter.
The real question:

Is there a more elegant way of achieving this? For example, is there a way
of getting the VS2005 IDE to tell me what the ID prefix would be?
Thanks for any help.

Al
Nov 13 '06 #1
1 1865
skip the id altogether.

ctl.AddAttribut e('onkeyup',str ing.Format('tex tareamax(this,{ 0});',maxlength ));

in client

function textareamax(e,m ) {
if (e.value.length m) e.value = e.value.substr( 0,m);
}

-- bruce (sqlwork.com)
"Alec MacLean" <al**********@N O-SPAM-copeohs.comwrot e in message
news:u6******** *****@TK2MSFTNG P03.phx.gbl...
Hi,

Outline of problem:

I've built a set of user controls that are used to output questions for a
survey and gather the responses using simple radio buttons.

I'm adding an optional textbox to the question control to allow individual
typed responses per question. I've got a maximum length to enforce which
matches the underlying data table design.

When asp.Net outputs a textbox set to multiline mode, the server actually
outputs a textarea tag. Fine, but I've found that the MaxLength property
seems to get ignored. I have previously got around this by providing a
javascript function to update a display of the characters remaining and
adding an Attribute to the specific textbox when the page loads that fires
the javascript function on the "onkeyup" event.

The javascript is straight-forward enough and the function allows a pair
of object names to be passed in, which correspond to the text entry
textbox and the chars remaining display textbox.

The issue I am having a problem with is that due to the question control
being repeated multiple times down the page, the server also adds a custom
prefix to each element ID that extends the original ID, so when I need to
add the attribute, I also need to know the adjusted ID of the specific
instance of the textbox.

Example output steps:

1. Out put header label values
2. Start outer loop to output question block header
3. Step 2 makes call to a second loop that outputs questions for the block

For example, the original ID of "txtResText " might become
"ctl109_txtResT ext", with the "ctl109_" bit varying according to how many
instances of the textbox there are. This is complicated a little as the
question control is not the only control being added to the page. There
are a set number of "static" controls that are output from the database.
This is important as it makes the starting number of the prefix higher
than a simple zero-indexed count of the question control on its own.

Say I have three "normal" labels populated before the repeated controls
are reached. These controls ID's remain unaffected, but they make the
prefix of the repeated control ID's start at "ctl104_".
My proposed solution:

I could use this knowledge to create a counter (with an offset to
accomodate the non-looped controls) that increments along with the output
loops of the various user controls, but this seems like a "hammer to crack
a nut" approach. Also, If I ever wanted to add further output prior to
the loops starting, I would have to remember to adjust the offset of the
counter.
The real question:

Is there a more elegant way of achieving this? For example, is there a
way of getting the VS2005 IDE to tell me what the ID prefix would be?
Thanks for any help.

Al

Nov 13 '06 #2

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

Similar topics

8
10014
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
2
5286
by: Praveen | last post by:
Hi All, I have made a webservice in C# and it works fine in my machine. I ran into a crazy problem when I wanted to deploy it in windows 2003 server. I have run "aspnet_regiis.exe -i" to make sure that the extensions for .asmx file etc are in place. I am getting http 404 when I give the url for the asmx file. the http error code is wrong because I am dead sure that the file is there. could you please let me know what else needs to be...
14
4447
by: Ankit Aneja | last post by:
The code of classes given below is for server to which clients connect i want to get ip address of client which has connected pls help how can i get //listen class public class listen {
3
4075
by: Rahul Anand | last post by:
As per our requirements we have a web service which internally connects (Simple HTTP Post Request) to a remote server to initiate some work. We are calling the web service method asynchronously from a .NET Web Application hosted on IIS. In our setup the web request form a client can be running for long duration (may be more than 4 hours). We are getting exceptions during the HTTP send/receive inside the web service method. The exception...
1
1407
by: Nurm | last post by:
We have a live webserver that is running .net 1.1 and 2.0 (mainly 1.1 websites). This morning we put a .net 2.0 test website onto the server and are getting http 404 errors. The 2 different versions of the framework are on different application pools. Both versions of the asp.net are allowed, but we are getting this 404 error. Share point is not on that server. The database server is on the same server and is sql server 2000. This server...
41
3525
by: LayneMitch via WebmasterKB.com | last post by:
I was just chating with a few webdevelopers and it was brought to my attention that I need some type of server technology installed on my computer so I could get a visual of how my sites would look on the web. I'm completely new to the server technology stuff and don't need anything expensive - only for testing purposes and so other web artists can see my work and give me their opinion/suggestions. What is the process of getting...
1
4742
by: =?Utf-8?B?Q29kZVNsaW5nZXI=?= | last post by:
I plan to build my own 2008 Server/Hyper-V system and will not be using one of the tested Dell or HP systems from the release notes and could use some pointers as to my assumnptions and answers to a few questions. Some getting started with Hyper-V assumptions. Please tell me if I am off base here. 1. Any recent Intel quad core processor has the needed x64 architecture with hardware assisted virtualization and data execution protection...
1
1619
by: Rahul | last post by:
I am getting following error: 1) For a xml file "Request.xml" we created a schema "Request.xsd". 2) With the help of xsd.exe we got the C# file Request.cs. 3) We tried to send the object of Request.cs to a webservice method SaveRequest(Request req). 4) Scenario is like same Request.cs is referenced by both server and
2
4604
by: Scott | last post by:
I'm debugging an xmlrpc client/server application. Often when an exception occurs in the server, I receive only a very short error message on the client. For example: xmlrpclib.Fault: <Fault 1: "<type 'exceptions.AssertionError'>:"> Presumably this is because xmlrpclib on the server is catching the exception, and only sending the exception name to the client, not the server's stack trace.
1
1836
by: Ramchandar | last post by:
Hi, I have an ASP.Net web application hosted in my local server with IIS 5.0 as web server. This worked fine with no issues. So I tried hosting the same into the server machine where I have IIS 6.0 as web server. I am having an issue : Onclick of the submit button the session variables are getting cleared. I don’t know why it is happening. I am not able to find why and where the session variables are getting cleared. Is there any setting...
1
9236
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
9182
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...
0
8186
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
6735
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
6031
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
4550
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.