473,385 Members | 1,821 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,385 software developers and data experts.

Raise an event from server side control

Can someone tell me how to raise an event or trap when the maxlength of a
server side textbox has been reached?
Nov 19 '05 #1
6 2789
You need to use client-side script to handle the onkeydown, keypress or
onkeyup events. Here's an exmple that handles the events and displays the
key codes - should work on all modern browsers:
http://www.daveandal.net/books/6744/...-mappings.aspx

This example uses the keycodes to create a masked edit control, showing how
you can managet he content of the text box:
http://www.daveandal.net/books/6744/.../maskedit.aspx

"Tim Westmoreland" <Tim We**********@discussions.microsoft.com> wrote in
message news:E6**********************************@microsof t.com...
Can someone tell me how to raise an event or trap when the maxlength of a
server side textbox has been reached?

Nov 19 '05 #2
What if the textbox is in an editable datagrid and you don't know what the id
is?

"Alex Homer" wrote:
You need to use client-side script to handle the onkeydown, keypress or
onkeyup events. Here's an exmple that handles the events and displays the
key codes - should work on all modern browsers:
http://www.daveandal.net/books/6744/...-mappings.aspx

This example uses the keycodes to create a masked edit control, showing how
you can managet he content of the text box:
http://www.daveandal.net/books/6744/.../maskedit.aspx

"Tim Westmoreland" <Tim We**********@discussions.microsoft.com> wrote in
message news:E6**********************************@microsof t.com...
Can someone tell me how to raise an event or trap when the maxlength of a
server side textbox has been reached?


Nov 19 '05 #3
I use the trick of creating the client-side function call in ASP.NET in the
ItemDataBound event for each row of a grid, and passing the ID of the
control to the function so it can be located in the client-side script.
You'll have to include the grid control ID as well as the textbox control ID
in the correct combination ("parentID_textboxID").

There's a heap of samples at:
http://www.daveandal.net/books/6744/samples.aspx
that do similar stuff. The Using a Client-side Confirmation Dialog one binds
a client-side event to every button in a Datagrid, and the various User
Control and Server Control examples do the same kind of thing with a number
of parameters passed to the client-side code to locate controls in the page
in the client-side code. You can download all the samples from:
http://www.daveandal.net/books/6744/

"Tim Westmoreland" <Ti*************@discussions.microsoft.com> wrote in
message news:D6**********************************@microsof t.com...
What if the textbox is in an editable datagrid and you don't know what the id is?

"Alex Homer" wrote:
You need to use client-side script to handle the onkeydown, keypress or
onkeyup events. Here's an exmple that handles the events and displays the key codes - should work on all modern browsers:
http://www.daveandal.net/books/6744/...-mappings.aspx

This example uses the keycodes to create a masked edit control, showing how you can managet he content of the text box:
http://www.daveandal.net/books/6744/.../maskedit.aspx

"Tim Westmoreland" <Tim We**********@discussions.microsoft.com> wrote in
message news:E6**********************************@microsof t.com...
Can someone tell me how to raise an event or trap when the maxlength of a server side textbox has been reached?


Nov 19 '05 #4
Thanks a lot. You've been a big help.

"Alex Homer" wrote:
I use the trick of creating the client-side function call in ASP.NET in the
ItemDataBound event for each row of a grid, and passing the ID of the
control to the function so it can be located in the client-side script.
You'll have to include the grid control ID as well as the textbox control ID
in the correct combination ("parentID_textboxID").

There's a heap of samples at:
http://www.daveandal.net/books/6744/samples.aspx
that do similar stuff. The Using a Client-side Confirmation Dialog one binds
a client-side event to every button in a Datagrid, and the various User
Control and Server Control examples do the same kind of thing with a number
of parameters passed to the client-side code to locate controls in the page
in the client-side code. You can download all the samples from:
http://www.daveandal.net/books/6744/

"Tim Westmoreland" <Ti*************@discussions.microsoft.com> wrote in
message news:D6**********************************@microsof t.com...
What if the textbox is in an editable datagrid and you don't know what the

id
is?

"Alex Homer" wrote:
You need to use client-side script to handle the onkeydown, keypress or
onkeyup events. Here's an exmple that handles the events and displays the key codes - should work on all modern browsers:
http://www.daveandal.net/books/6744/...-mappings.aspx

This example uses the keycodes to create a masked edit control, showing how you can managet he content of the text box:
http://www.daveandal.net/books/6744/.../maskedit.aspx

"Tim Westmoreland" <Tim We**********@discussions.microsoft.com> wrote in
message news:E6**********************************@microsof t.com...
> Can someone tell me how to raise an event or trap when the maxlength of a > server side textbox has been reached?


Nov 19 '05 #5
if you set a the 'MaxLength' for a text it will not allow you to type text
longer than the 'MaxLength'

HTH

Ollie Riches

"Tim Westmoreland" <Ti*************@discussions.microsoft.com> wrote in
message news:17**********************************@microsof t.com...
Thanks a lot. You've been a big help.

"Alex Homer" wrote:
I use the trick of creating the client-side function call in ASP.NET in the ItemDataBound event for each row of a grid, and passing the ID of the
control to the function so it can be located in the client-side script.
You'll have to include the grid control ID as well as the textbox control ID in the correct combination ("parentID_textboxID").

There's a heap of samples at:
http://www.daveandal.net/books/6744/samples.aspx
that do similar stuff. The Using a Client-side Confirmation Dialog one binds a client-side event to every button in a Datagrid, and the various User
Control and Server Control examples do the same kind of thing with a number of parameters passed to the client-side code to locate controls in the page in the client-side code. You can download all the samples from:
http://www.daveandal.net/books/6744/

"Tim Westmoreland" <Ti*************@discussions.microsoft.com> wrote in
message news:D6**********************************@microsof t.com...
What if the textbox is in an editable datagrid and you don't know what the
id
is?

"Alex Homer" wrote:

> You need to use client-side script to handle the onkeydown, keypress
or > onkeyup events. Here's an exmple that handles the events and displays the
> key codes - should work on all modern browsers:
> http://www.daveandal.net/books/6744/...-mappings.aspx
>
> This example uses the keycodes to create a masked edit control,
showing how
> you can managet he content of the text box:
> http://www.daveandal.net/books/6744/.../maskedit.aspx
>
> "Tim Westmoreland" <Tim We**********@discussions.microsoft.com>
wrote in > message news:E6**********************************@microsof t.com...
> > Can someone tell me how to raise an event or trap when the

maxlength of a
> > server side textbox has been reached?
>
>
>


Nov 19 '05 #6

use RegisterClientScriptBlock:

RegisterClientScriptBlock("clientScript", "<script
language=JavaScript>alert('Hello ');</script>");
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #7

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

Similar topics

1
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
2
by: Andrew | last post by:
Hi, friends, I need to raise certain events in my VC# windows control library. Any reference paper or sample source code for help? Thanks a lot...
2
by: Oney | last post by:
I want to open a popup window when user click the web server button control When user click the button, only OnClik="OpenWindow(12)" is sent but no event happend no popup opened.After...
19
by: Sjaakie Helderhorst | last post by:
Hello, I need to add a Javascript event (onClick) to a servercontrol (asp:checkbox). Checkbox is named 'cbDoMail'. Assumed that 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()") would do...
4
by: Barb | last post by:
I have a user control as my Save button for my page. When the Save button is clicked, I want some client-side validation to take place from a javascript function in the page, and then I'd like the...
2
by: The Crow | last post by:
i want to raise an event on the server with a javascript call on the client. i found a solution but i think its not so elegant. the solution is: i call __doPostBack("RefreshPage", ""); from...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.