473,771 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handling OnClick and GetPostBackEven tReference

I am writing a control and want to handle an OnClick event on the client-side
before then conforming to the postback mechanism. I have got the server-side
events working for my OnClick event by adding to the rendered element's
OnClick handler using GetPostBackEven tReference. How can I provide a
client-side onclick handler and then to use the aspnet form submit method
such that I can also subscribe to the server-side events too?

Mar 5 '07 #1
2 18564
define a property (say OnClientClick) then if set add it to the onclick
attribute before the get:

writer.AddAttri butes("onclick" ,
OnClientClick + GetPostBackEven tReference(opti ons);
-- bruce (sqlwork.com)
Mark wrote:
I am writing a control and want to handle an OnClick event on the client-side
before then conforming to the postback mechanism. I have got the server-side
events working for my OnClick event by adding to the rendered element's
OnClick handler using GetPostBackEven tReference. How can I provide a
client-side onclick handler and then to use the aspnet form submit method
such that I can also subscribe to the server-side events too?
Mar 5 '07 #2
Bruce,

Thanks for the reply. My question wasn't really worded very well and of
course your suggested code is the simple part which I have done. My question
was really about the way in which GetPostBackEven tReference was working. I
had set-up my client-side handler using javascript passing a var from the
onclick call as you suggested. My problem was with the output of the asp.net
method GetPostBackEven tReference of the ClientScriptMan ger class as below;

__doPostBack('c tl00$BDTabMenu1 ','Menu1');

Because, I had passed a var to my function i.e. funtion fname(x) {....}

I was trying to find a way to output a varname in the argument part of the
GetPostBackEven tReference but couldn't get round the way it was rendering it
in a string! My fix was to iterate over my data source and output script for
a switch statement, then allowing me to use the explicit
__doPostBack('c tl00$BDTabMenu1 ','Menu1'); calls in each case, as below;

switch(x)
{
case 'Menu1' :
{
aElement.value= 0;
__doPostBack('c tl00$BDTabMenu1 ','Menu1');
break;
}
case 'Menu2' :
{
aElement.value= 1;
__doPostBack('c tl00$BDTabMenu1 ','Menu2');
break;
}
}

anyway, I now have a different gripe with master and content pages and
events within my custom control, which I have posted to verious other threads!

Thanks again!

"bruce barker" wrote:
define a property (say OnClientClick) then if set add it to the onclick
attribute before the get:

writer.AddAttri butes("onclick" ,
OnClientClick + GetPostBackEven tReference(opti ons);
-- bruce (sqlwork.com)
Mark wrote:
I am writing a control and want to handle an OnClick event on the client-side
before then conforming to the postback mechanism. I have got the server-side
events working for my OnClick event by adding to the rendered element's
OnClick handler using GetPostBackEven tReference. How can I provide a
client-side onclick handler and then to use the aspnet form submit method
such that I can also subscribe to the server-side events too?
Mar 6 '07 #3

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

Similar topics

4
2822
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow the user to select multiple files. As you may know, the tag produces a text input field with an adjacent button for selecting a file from the local file system. As I would like to be able to allow the user to upload an arbitrary number of files...
4
1754
by: hillcountry74 | last post by:
Hi, I'm a newbie and trying to understand event handling in c#. I have understood handling events using delelgate objects. But not this method- "Event handling by overriding the virtual protected method of the base class". Can someone please explain this with a sample code? Thanks a lot.
4
1735
by: Samuel Hon | last post by:
Hi I'm building a custom control which basically takes data from the user and then submits it. I would use the validator controls but if I understand correctly (I've been working with .Net for 2 weeks) you cant 'embed' them in the custom controls. Someone correct me if I'm wrong (and please point to an example :) ) So, to get around this, I'm using Javascript. In my control, I'm doing
13
5678
by: Chris | last post by:
I can create Javascript confirm message boxes during page creation, etc adding them to the button attributes (many good posts on this!). But how can I add this event after the button is pressed? I have created an Is_Dirty routine checking for field changes on my page then if the user clicks on the "exit" button I check for Is_Dirty = true and want to ask then "do you want to exit without saving?". It's a code behind where if the value of...
4
2123
by: Tad Marshall | last post by:
Hi, I'm having limited luck getting an ApplicationException to work right in my code. This is VB.NET, VS 2003, Windows XP SP2, .NET Framework 1.1. I thought it would be convenient to take advantage of exception handling to deal with the case of the user clicking the Cancel button while a long operation was running. So, I declared a class inherited from ApplicationException and I Throw one of these with the text "User pressed Cancel"...
2
7718
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the submit button to submit a form that contains one or two Mileposts: 1) If a Milepost range larger than 5 miles is entered, I would like to pop up a confirmation box to confirm the range.
0
2688
by: Boricua | last post by:
I'm using ASP.NET 2.0 I got an imagebutton at the end of my form as a submit button. When the user clicks it the button becomes disabled and continues with the postback. This is what I got, ib is the imagebutton. Dim sbValid As New StringBuilder() sbValid.Append("if(typeof(Page_ClientValidate)=='function'){ ") sbValid.Append("if (Page_ClientValidate() == false) { return false; }} ")
3
5710
by: Tomasz J | last post by:
Hello Developers, How do create a custom WebControl (not UserControl), exposing OnClick event? I reviewed countless examples found by Google, but came across nothing helpful. Below I attach what I got so far. Thank you for any hints. Tomasz J
0
3626
by: dhyder | last post by:
I'm working on an admin page for a SQL Server 05 db. The page is in ASP.NET 2.0/C#. The db has multiple tables with foreign keys/constraints. I have multiple SqlDataSources and GridViews, which are doing the select/update/delete methods. I manually did the Insert method for each Gridview and I am able perform error handling on it. Textboxes for data to add <asp:Button ID="btnInsertNewService runat="server" Text="Submit"...
0
9619
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
9454
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
10102
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
10038
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
9910
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
6712
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
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
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.