Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2006, 06:02 AM
Authorized User
 
Join Date: Aug 2006
Posts: 39
Thanks: 1
Thanked 0 Times in 0 Posts
Default Link Button does not work properly

Hello,

I've two LinkButtons on form. First link button updates time, second calls javascript function. Untill I click second, first works properly. As I click second, after then first does not work at all.

My code is as follows:

<%@ Page Language="C#" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LinkButton1.Text = "Time: " + System.DateTime.Now.ToLongTimeString();
            LinkButton2.PostBackUrl = "javascript:SayHello();";
        }
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        LinkButton1.Text = "Time: " + System.DateTime.Now.ToLongTimeString();
    }
</script>

<html>
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
        function SayHello()
        {
            alert("Hello");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click"></asp:LinkButton>
        <asp:LinkButton ID="LinkButton2" runat="server">Say Hello</asp:LinkButton></div>
    </form>
</body>
</html>

Any idea? :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Link button in nested grids clcik doesnt work fir RaghaSM ASP.NET 2.0 Basics 1 June 26th, 2008 12:05 AM
Doesn't work properly for multiple file arguments. sbubendorf VBScript 7 September 20th, 2007 08:52 AM
Stored procedures won't work properly... eBilyboy SQL Server 2000 1 December 12th, 2005 11:25 AM
vc++2003 can't link properly. Kilka Visual C++ 1 March 15th, 2005 06:43 AM
Can't Get Percent Format to Work Properly twsinc Access VBA 2 November 19th, 2004 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.