.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

Using an onclick event to create a timestamp

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net

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)

View Complete Post

More Related Resource Links

file upload in Create User Wizard Created User event with UpdatePanel Tag wont work?



In my Create User Wizard1 Created User Wizard Event, I am collecting extra information from text boxes and allowing

the user to uplad a file.



I have put the Submit button within an Update Panel Tag but since I have done this it does not work.

Is there a way round it. In this situation would you use a trigger.?


<br />

  <asp:UpdatePanel ID="UpdatePanel2" runat="server">

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  align="middle"
                                            Text="Submit my Profile" />

How to create an event?

How to create an event? Please help.

Create a meeting instance with an event handler

Hi, i want to know if its posible to insert a new meeting instance in a meeting workspace automatically when you add a new event in a calendar.   i try to pass automatically the option of the template selection.   its posible with the objetc model or web services?   thanks

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.              

Create an Event Handler to catch calls to Create.aspx

Hi, I want to research creating an event handler/reciever to catch calls (mouse clicks) to Create.aspx to prevent users having the ability to create new content. I've noticed in VS2010 the templates for Event Recivers you do not get anything similar that I could use as a starting point (List Events, List Item Events etc) Any ideas how I can define a new type of event receiver?

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

Create linkbutton (onClick) Dynamically


I am trying to create a Linkbutton inside a calendar.  Everything works except for the onClick.

Is there a way to make this work?


Dim dailyEventLabel As New LinkButton

dailyEventLabel.ID = "CalLink"

dailyEventLabel.ToolTip = _myDataSet.Tables("events").Rows(countrows).Item("Event_date")

dailyEventLabel.Text = _myDataSet.Tables("events").Rows(countrows).Item("Eventname")

dailyEventLabel.Attributes.Add("AutoPostback", "true")

dailyEventLabel.OnClick = LinkButton1_click()



End If

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

Create column In Datalist On DataBound Event


Hi ,

 I have a condition on which i have to set the column of the datalist at run time.

IT may be 2,3 or 4 at run time.

How i do it. plz replay as soon as possible.

Is this possible that on the item bound event i set the html <tr><td>.

IF Yes Then How.


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

how to create date time event in sharepoint workflow



I want to change the status of a list item one month after its approval. which event should i fire and how do i do it in workflow. any idea.



How to create wsdl proxy of web service with out event handler for .net compact framework 4


Hi All

i have one problem while access web service axis 1.4 in compact frame work

Create web service object using client

 MIScreenSoapClient ser = new MIScreenSoapClient();

create event handler for method to access web service

ser.GetLoginRequestCompleted += new EventHandler<GetLoginRequestCompletedEventArgs>(proxy_getloginrequest);
    ser.GetLoginRequestAsync(strLogin, strPass, Program.VersionNumber, "WM1", "test", "WP7");

Event Handle for method

 void proxy_getloginrequest(object sender, GetLoginRequestCompletedEventArgs e)
   string eee = e.Result;
is there any way to access webservice without call event handler?
Please help me


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

Checkbox ot displaying, please help, i want the check box to create a row check type of event.


string Data_source=@"Data Source=A-63A9D4D7E7834\SECOND;";

string Initial_Catalog=@"Initial Catalog=replicate;";

string User=@"User ID=sa;";

string Password=@"Password=two";

string full_con=Data_source+Initial_Catalog+User+Password;

SqlConnection connection = new SqlConnection(full_con);


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" %>

How to Create WPF button dynamically + route button event dynamically





 Window1 : Window





 sender, RoutedEventArgs e)
  // do something





 sender, RoutedEventArgs e)
   string xml = "<Button xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'";
xml += " xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'";
xml += " Height='26' Margin='45,0,0,30'";
xml += " Name='button3'";
xml += " VerticalAlignment='Bottom'";
xml += " HorizontalAlignment='Left' Width='65'>Test</Button>";

Stream strm = new MemoryStream(ASCIIEncoding.Default.GetBytes(xml)); Button myButton = (Button)System.Windows.Markup.XamlReader
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