Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6906619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:19:58+00:00 2026-05-27T08:19:58+00:00

net/C# application I have a Link button: <asp:LinkButton runat=server ID=LinkButton1/> When the user clicks

  • 0

net/C# application I have a Link button:

<asp:LinkButton runat="server" ID="LinkButton1"/>

When the user clicks this button I want to execute this javascript function:

document.getElementById('LinkButtonPrevious').click();

And change a Session variable:

Session["ID"] = 2;

The problem is that the session variable can only be changed in the code behind.

How can I execute both when the link button is clicked?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:19:59+00:00Added an answer on May 27, 2026 at 8:19 am

    Changing a value server side requires either a full post of the page or an ajax call.

    So you could add a HiddenField and set its value to 2 client side, and then in your server side button handler use that value to set the session variable.

    Or you could do an ajax call to a web service.

    As far a performing client and server side operations on the same click event, you can do the following. Add a server side Click handler as usual, then register a client side event with ClientScriptManager.RegisterOnSubmitStatement. Here’s the example from MSDN:

    <%@ Page Language="C#"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
      public void Page_Load(Object sender, EventArgs e)
      {
        // Define the name and type of the client script on the page.
        String csname = "OnSubmitScript";
        Type cstype = this.GetType();
    
        // Get a ClientScriptManager reference from the Page class.
        ClientScriptManager cs = Page.ClientScript;
    
        // Check to see if the OnSubmit statement is already registered.
        if (!cs.IsOnSubmitStatementRegistered(cstype, csname))
        {
          String cstext = "document.write('Text from OnSubmit statement');";
          cs.RegisterOnSubmitStatement(cstype, csname, cstext);
        }
    
      }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
      <head>
        <title>ClientScriptManager Example</title>
      </head>
      <body>
         <form    id="Form1"
                runat="server">
         <input type="submit"
                value="Submit" />
         </form>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an ASP.NET/C# Application. I have Link buttons like this <asp:LinkButton
I use yui datatable in my asp.net application... I have a link button in
In my ASP.Net application I have a requirement that when a user clicks on
I have silverlight application. What I want is. If my user clicks on Button
In my ASP .NET MVC application i have a link that refreshes the preview
I have a VB.net test application that clicks a link that opens the Microsoft
I am using one link button in an asp.net application for delete purpose. For
okay, so i have an asp.net (C#) application and i want to add a
I have an ASP.NET c# web application published to a server of ours. It
We have an ASP.NET C# web application with a printer friendly link. Is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.