.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

onclick event in table

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net

Hi,I want to add an onclick event on tablerow(which can make changes in another asp.net page) ,but I do not how to do this. And alsow I use Masterpage, mabe I need to add some code in this page too,this tablerow in the Masterpage.Can you help me?


Cry please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



View Complete Post

More Related Resource Links

Triggering an event to occur within a VB.NET app if something is inserted into an SQL Server table

Let's say SQL Server is inserting arow within a table. Is there a way to let VB.NET know that an event was fired (being the inserting of the row within the table), without the need to query anything. Bascially having SQL Server tell the VB.NET app that an event was fired. It seems like it might be possible using CLR and the .NET framework integration wthin SQL Server, but I haven't found a sample program showing what I'm attempting. I understand that this topic covers SQL Server and VB.NET.  This need being for both and this forum only set for SQL Server, I thought I'd take the risk and post in this forum. Thank you in advance for any assistance.Newbie

Treeview node to add onclick event to download files

 Hi, I would like to know how to add onclick evend to a TreeNode so that the file can be downloaded.   How can I implement below sample code to a TreeNode? <a href="#" onclick="popup('/directory1/Somefile.doc'); return false;" target="download"> Somefile </a> <script language="javascript"> function popup(url) { popWin = window.parent.open(url, 'popWindow', 'height=900, width=900, toolbar=no, menubar=yes, scrollbars=yes, titlebar=no, resizable=yes,location=0, directories=no, status=no'); } </script> I have TreeNodePopulate event to populate nodes like this: protected void DocRepository_TreeNodePopulate(object sender, TreeNodeEventArgs e) { .... String[] files = Directory.GetFiles(fullPath); foreach(String file in files) { TreeNode newNode  = new TreeNode(Path.GetFileName(file), Path.GetFileName(file)); node.ChildNodes.Add(newNode); } }   Thank you in advance.              

asp:Button inside a SharePoint Dataview's Rows with onclick event does not call C# function. Pull i

asp:Button inside SharePoint Dataview Rows with onclick event does not call C# function. Pull it out of Dataview and works fine. I have a ASP.NET Button I've placed inside a SharePoint  DataView's rows with an onclick event pointing to C# function block inside my page. The page refreshes when I click on them, but it's not hitting that code block. If I move the button to outside the dataview and make the ID fixed, the code works beautifully. what's up with that? the button in the Dataview: td class="ms-vb" style="width: 70px"><asp:Button runat="server" Text="Delete" id="Delete{@ID}" CommandArgument="{@FileRef}" OnClick="DeleteDoc"/> </td> my C# onclick handler (inline C# on the page) void DeleteDoc(object sender, EventArgs e) { Button b = sender as Button; .. more code The buttons are rendered and they look like this: input type="submit" name="ctl00$PlaceHolderMain$g_08acadfd_957b_4112_a426_cc7c81991c1e$Delete1" value="Delete" id="ctl00_PlaceHolderMain_g_08acadfd_957b_4112_a426_cc7c81991c1e_Delete1" Thie code block in inline and I'm working from SharePoint Designer. Not sure how I can troubleshoot this.  Am I missing something here, maybe I need to add an Itemtemplate or something like we need to in the ASP.N

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

Button OnClick event not working.


Hi folks,

I am having trouble with two buttons on a page. I dragged them on to the page and then double- clicked each of them in order to create the OnClick events.

I added my code to the events, but when I click the buttons, their respective events aren't being called.

I am very confused!

Any help is appreciated, thanks!

My .aspx code:

<asp:Button ID="Button3" runat="server" Text="Accept" CausesValidation="true" onclick="Button3_Click" />
        <asp:Button ID="Button4" runat="server" Text="Reject" CausesValidation="true" onclick="Button4_Click" />

My Code behind:

protected void Button3_Click(object sender, EventArgs e)
        int id = int.Parse(queryString);

        #region LiveDatabase
        //string connection = ConfigurationManager.ConnectionStrings["LiveDatabase"].ToString();

        #region MySqlDatabase
        string connection = ConfigurationManager.ConnectionStrings["MySqlDatabase"].ToString();

        MySql.Data.MySqlClient.MySqlConnection MyConn = new MySql.Data.MySqlClient.MySqlConnection(connection);

        string query = "UPDATE p

Bug? OnClick event prevents postback on CommandField BUTTONs


This has been asked a few times before but I can't find a definitive answer.  If I have a delete button in a commandField and programmatically add an OnClick javascript confirm, then the page never posts back after the dialog appears.  When using the same approach using a LINKBUTTON, everything works perfectly.  Is there any way to get this functionality to work using BUTTONs??

This works fine (using a LINKBUTTON):

<asp:CommandField Visible="false" ItemStyle-Width="150" ButtonType="Link" ShowDeleteButton="true" DeleteText="Delete" />

Sub gvRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.RowState = DataControlRowState.Normal OrElse e.Row.RowState = DataControlRowState.Alternate Then
e.Row.RowState = 0 OrElse e.Row.RowState = 1 Th

Problems capturing a Click event from a button inside an asp:table


Hi, I am developing a web site to display some data that is inside a database.

To do this I've created an ASPX web page that opens a connection to a database and retrieves the desired data. After that it populates an asp:table object dynamically.

The problem is that some of the fields that are retrieved from the database are too large to be displayed on the web page, so I decided to make a popup that would be able to display just the desired field.

To do this I've added a button to the asp:table so that when the user clicks it the popup would appear with the contents of the field. However what is happening is that when the user clicks on the button, the page just gets reloaded and the Click event handler is never called.

Below is the code in which I add the button to a TableCell, and the TableCell to the TableRow collection:

// Coluna Mensagem Formatada.
celula = new TableCell();
celula.HorizontalAlign = HorizontalAlign.Center;
Button button = new Button();
button.Text = "...";
button.Click += popupHandler;


Please note that the popupHandler is a delegate to the function below. I am using it as a the Click event handler for testing purposes.

protected void abrirPopup(object sender, Even

Using an onclick event to create a timestamp


I have a web site with a button onclick event and when a user clicks on the button I want that to create a timestamp event in my SQL server. I have the following default.aspx.vb code:

Imports System.Data.SqlClient
Imports System.Data

Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub
    Public Sub InsertRow()
        Dim myConnectionString As String = "Initial Catalog=mdr;Data Source=xxxxxx;uid=xxxx;password=xxxxxxx;"

        Dim myConnection As New SqlConnection(myConnectionString)
        Dim commandText As String = "insert into Exceptions (employeenumber, exceptiondate, starttime, endtime, duration, code, approvedby)" & _
        " values (@employeenumber, @exceptiondate, @starttime, @endtime, @duration,@code, @approvedby)"

        Using connection As New SqlConnection(myConnectionString)
            Dim command As New SqlCommand(commandText, connection)

            command.Parameters.Add("@employeenumber", SqlDbType.VarChar)
            command.Parameters("@employeenumber").Value = OperatorDropdown.SelectedItem.Text

            command.Parameters.Add("@exceptiondate", SqlDbType.DateTime)

Event Handlers need to return the actual table, column and value of column and name of task which tr



Within SQL 2005 within the Event Handler tab I created a an Execute SQL Task with the following SQL statement; -

INSERT INTO dbo.CustomSSISLog (SourceName, SourceDescription, ErrorDescription,PackageName,ErrorCode,TaskName) VALUES (?,?,?,?,?,?)

In conjunction with using the Parameter Mapping tab to map parameters to system variables the above work's quite well. However the TaskName contains the name of the task which inserts the error record, I want it to contain the name of the Task (SSIS component) which triggered the error.

Also I need the error record to contain the actual table, column and value in the column which triggered the error, any ideas? There does not seem to be readily available system variables to do this.

Kind Regards,


If you have found any of my posts helpful then please vote them as helpful. Kieran Wood MCTS BI, PGD SoftDev (Open), MBCS http://uk.linkedin.com/in/bileeds

Adding script to an onClick event in a Hyperlink control



I need a little help with the formatting for an on click event in a hyperlink control:

<asp:HyperLink ID="HyperLink" runat="server" onclick="test('<%=Page.ResolveUrl("~/secure/club-officials/add-new-official.aspx")%>');" >Add New Official</asp:HyperLink>

I get an error with the using the <% %> within the onclick.

Many thanks

how to add multiple rows in a data table against a button click event


how to add multiple rows in a data table against a button click event, and then show it in a gridview

Button onClick event not firing in Safari 5


Hello All.

I'm am fairly new to ASP.NET and have been experiencing quite an odd problem.  My application works just as I expect it to in IE7 and FF. However, once tested in Google Chrome or Safari, I start to experience issues with the firing of my onClick event.  In Chrome or Safari 4, when I click my button control, it does not seem to recognize that the button has been clicked at all and my onClick event is never fired.  However, upon clicking it a second or third time, it fires.  Annoying.  The real problem is with Safari 5.. No matter how many times I click the button, nothing happens.. Yet I have found that if I tab down to the button and select it using the space bar, it fires... ?? So, I have done a great deal of digging and have found very few posts that describe something similar.  I have read that Chrome and Safari report themselves as WebKit in their userAgent strings, but I believe that only comes into play when using AJAX.  


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

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

Button onclick event not firing when some AJAX controls are introduced



I have a web page which has both asp.net controls as well as AJAX controls.I am facing a weird issue when I introduce some AJAX controls(Modal popup) inside a tabbed panel, the button onClick event stops firing.Can anyone suggest what might be the reason for this?

Here is my code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Entity.aspx.cs" Inherits="Entity" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="HeaderImagePlaceHolder" Runat="Server">
<img src="images/image5.jpg" alt="NewsPageImage" />
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager_TabContainer" runat="server">
      <asp:TabContainer ID="TabContainer_Metadata" runat=&q

Keeping onclick event after postback


We have a 3 tab setup using css and the following javascript, if im on tab2 or tab3 and i submit the form within that tab, when the page posts and reloads, the tab defaults to tab1

Is there anyway to update this logic to keep the viewstate or would i be better off going with the tab control for our page?

        function goSearchOption(theoption) {
            for (var i = 1; i <= 3; i = i + 1) {
                if (i != theoption) {
                    document.getElementById('searchOption' + i).style.display = "none";
                    document.getElementById('nav' + i).setAttribute("class", "searchnav");
                else {
                    document.getElementById('searchOption' + i).style.display = "block";
                    document.getElementById('nav' + i).setAttribute("class", "searchnavHL");



Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

Insert value using Table Value Functions

a real gem in Sql Server 2008. mostly people still using Stored procedure may be they shifted to SQL Server but they are not using TVF right now.
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