.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how to impose javascript event processing?

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

If I have some form control like textbox and I want the event handler to be located in the html instead of at the server side, how to do that? Of course I can copy paste javascript code in the aspx file. But is it possible to do that using some object oriented approach (ie programmatically in the code behind)?


View Complete Post

More Related Resource Links

Closing Javascript Modal dialog window after server side event processing


Hello Friends..

Please tell me how to close Javascript ModelDoalog Window.. after Server Side event Processing .

Basically i want close window in  finally Block After sucessfulll Updation.

AMit..... InnocentInnocentInnocentInnocentInnocentInnocentInnocent

Trap Selected Index change event of listbox using Javascript.

Hi All, This is reagarding listbox selection. I have a list box with multi select option. I want to trap the selected index change event of Listbox through javascript. Item of list box can be selected using Click of mouse and also the keyboard up down key with shift. I tried onclick event to bind the javascript function. It works fine if I select by mouse, but it doesen't work for up/down key of keyboard. Thanks, Naveen

raise click event from javascript

HiI want to raise click event on linkbutton, when press "Enter ?" on textbox.I wrote this code:LinkButton1.Attributes.Add("onclick", myscript);but, can not call LinkButton1.onclick() , my linkbutton:href='javascript:WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$Login1$lbtEnter",%20"",%20true,%20"LoginGroup",%20"",%20false,%20true))'when call ctl00$ContentPlaceHolder1$Login1$lbtEnter.onclick();Error: ctl00_ContentPlaceHolder1_Login1_lbtEnter is not define

Viewstate issue when calling button click event from Javascript

I have a javascript that asks a confirmation on search click. If the user has made some changes to the data in grid (gridview) on click of Search, a confirmation is asked to Save or Continue Search. If Yes, Save the records by invoking Save click from javascript. If No, Search click is invoked. While Search click happens correctly, Save click results in an error which reads like this..  "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. " I know the Viewstate is what causing the problem, where the control is not loaded but script is trying to invoke it's click event. Any help is appreciated. At the end of the day, all i need is to invoke Save click from javascript.   -- Viswanth VG  

Execute Javascript from Sharepoint Event Handler

Hello, I want to execute a sample java script function from itemadding event of sharepoint event handler.  How can i achieve this? Please Help.   Thanks in Advance

Javascript Unload event

Hi,   Just a quick general question about javascript. Is it possible for the browser unload event not to fire sometimes? I have a webmethod that fires at the time the user closes , presses back, presses forward or refreshes the asp.net page.   Any known bugs in browsers that may prevent unload events from firing sometimes? I would like to hear somebody's opinion on this.    Thanks

Calling Button,s onclick event in javascript code


 Hi Experts.

I have a Button control in webpage.

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" OnClientClick="test()"/>

When i click on button, i want to check some conditions

How can i safe value of variables in javascript code in PostBack event?


Hi Experts.

I need to define some Boolean variables in my javascript code and use them  when  the any onfocusout methods of controls  is fired. Like this:


            Var is_ValidateTextBox1 = false;

            Var is_ValidateTextBox2 = false;

            Var is_ValidateTextBox3 = false;

Function focusout_TextBox1()

{ValidateTextBox1 = true; }


When onfocusout of TextBox1 is fire, I want to set  " is_ValidationTextBox1=true;".  But when the post back is fired from the form, the variable reset to false because the line of defining the "Var is_ValidateTextBox1 = false;" is run again in post back!

Now how can I to solve this problem? How can i safe value of variables in javascript code in PostBack event?

With Regards. Mojtaba

Onchange event for datetime field in javascript is not working?


I want to compare start date and end date when start date is changed. If start date is big, on change event i need to make the end date the same as start date.

So I wrote On change event for start date. But it doesnot work  

getField('input','Start Time').onchange = function() {showEndDate()};


function showEndDate()



var date1 = getField('input','Start Time');

var date2 = getField('input','End Time');


but its not firing at all. So you guys have any idea or any other way to do for datetime on change event?

How to trigger a JavaScript function using "onmouseover" event on a SPMenuField control?



I could do something along these lines for TemplateField (with ItemTemplate having a HyperLink control):

private void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
     if (e.Row.RowType == DataControlRowType.DataRow)    
          ((HyperLink)e.Row.FindControl("lnk_id")).Attributes.Add("onmouseover", "someFunction();");    

For SPMenuField, which control should I set the "onmouseover" event to?



How to call a javascript click event from ASPx?


this is kind of wierd but I need to use behindcode or aspx code to call a javascript click event.  The reason is because, I have two controls.  One control is a javascript controls tabs.  The other control is a panel.  The panel has a bunch of controls and depending on which tabs are being selected, the panel will switch to panel1,2,3,4 depending on if the user click tab1,2,3,4.

I've got the upper part programmed by using a __doPostback to the update panel.

However, in this case, I need to program the opposite because when the user switches the panel, the tab must be switched.

So here's what I got when a user clicks the tabs:

<a href="#" onclick="easytabs('1', '1');__doPostBack('UpdatePanel2', 'Tab1');return false;" onfocus="easytabs('1', '1');" title="" id="tablink1">

So I need a server side function such that when a user clicks <asp:LinkButton> or something, it will also call "easytabs('1','1');

How to track Collapse/ Expand event of AJAX Collapsible Panel Extender to call javascript ?



I am working with AJAX Panel Collapsable panel extender.

The Panel which is to be collapsed/Expanded using AJAX panel Extender contains one custom control, containing 3 Radio buttons one of them is set checked through a javascript function when page loads. I have kept the default property of AJAX collapsable panel as Collapsable.

Script for AJAX Collapsible Panel Extender is as follow. 

 <ajax:CollapsiblePanelExtender ID="cpeSOP" runat="Server" CollapseControlID="pnlCollapsable"
   CollapsedSize="0" Collapsed="True" CollapsedImage="~/public/img/arrowRightWhite.gif"
   ExpandControlID="pnlCollapsable" ExpandDirection="Vertical" ExpandedImage="~/public/img/arrowDownWhite.gif"
   ImageControlID="Image1" SuppressPostBack="true" TargetControlID="pnlSearchCriteria">

But problem is that when page loads, collapsible panel gets collapsed but it resets the radio buttons in custom control. i.e. First radio button does not get checked. Script for Collpsable panel is as follow. I want to call some javascript code when the panel is Collapsed or Expanded. Is there any way to track Coll

how to capture Clieck Event using javascript for pop up screen


Hi ,

I have code for popup screen , but i want to capture some value on click also ,from code behind but not able to capture


below are code 








string modaljs = "function " + radarLimitedCtl.ClientID + "OpenEnlargeMapModalPopup() { $('#" + pnlEnlargeRadar.ClientID + "').showModal(); document.getElementById('" + iEnlargeRadar.ClientID + "').src = '/Controls/Radar/Radar.aspx'; } function " + radarLimitedCtl.ClientID + "CloseEnlargeMapModalPopup() { $('#" + pnlEnlargeRadar.ClientID + "').hideMod

disable button in page load click event using javascript



i have button its  enable false in aspx page, if i click the page load  click event  then button should enable

looking forward the reply.

How to call javascript function from Button CLick event



I have a createuserwizard. My CompleteUserWizard in CreateUserWizard is like this..

<asp:CompleteWizardStep ID="MessageStep" runat="server">





  <table style="height: 100%; width: 100%;">


   <td align="center" colspan="2" class="complete_text">






  Your account has been successfully created.




     <td align="center" colspan="2">

    <asp:Button runat="server" ValidationGroup="Createuserwizard1" CommandName="Continue" ID="ContinueButton" CausesValidation="False" Text="Continue" Width="65px" CssClass="Base" />







radio button checked changed event not firing with onclick javascript function



I have used below code.

<asp:RadioButton GroupName="grpAssoc" ID="rbtEvery" runat="server" Text="Everyone"
                                                                                    onclick="return doChangeAssociationType(0);" AutoPostBack="True" oncheckedchanged="rbtEvery_CheckedChanged"

but oncheckedchanged="rbtEvery_CheckedChan

Javascript button click event oddity in FireFox


Hi Everyone -- This code works fine when outside of an UpdatePanel, but when inside, the server side event never gets called.  It works fine in IE (both inside and outside of an UpdatePanel).

Any Ideas?  Code to repro below:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server"></head>


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend