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

  • Home
  • SEARCH
  • 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 7941057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:33:07+00:00 2026-06-03T23:33:07+00:00

I want to access the server side variable in javascript alert. <asp:Button id=btnDelete runat=server

  • 0

I want to access the server side variable in javascript alert.

 <asp:Button id="btnDelete" runat="server" class="deleteicon" Text='<%# Eval("iuser_id") %>' OnClick="deleteclick" onclientclick="return confirm('Are you sure you want to delete this record?'+<%# Eval("struser_name") %>);"/>

This is a delete button in a gridview. On click of it I want to alert the message and the user name. I am getting server tag is not formattted error.

Thanks,

  • 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-06-03T23:33:09+00:00Added an answer on June 3, 2026 at 11:33 pm

    EDIT

    Attach javascript click function in rowDataBound event of the gridview safest and easy way to do it…code is as below

    protected void GridView1_RowDataBond(object source, GridViewRowEventArgs e) 
        { 
            if (e.Row.RowType == DataControlRowType.DataRow) 
            { 
                Button btnAlertStatus = (Button)e.Row.FindControl("btnAlertStatus"); 
    
                DataRowView drv = (DataRowView)e.Row.DataItem; 
    
                string username = drv["User_name"].ToString(); 
    
                btnAlertStatus.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this record?"+ username + "')"); //error because of javascript left one bracket
            } 
        }
    

    PRE

    Try

    JavaScript

    function confirmMsg()
    {
    
      var Variable = '<%= ServerVaraible %>';
      return confirm('Are you sure you want to delete this record?'+ Variable );
    }
    

    HTML

     <asp:Button id="btnDelete" runat="server" class="deleteicon" Text='<%# Eval("iuser_id") %>' OnClick="deleteclick" onclientclick="return confirmMsg();"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to access server side asp.net variable in javascript? I want
I want to access PHP(server side file variables) with JavaScript(Client side script) without using
I want to write a server side code in Java to access DB. A
I want to access selected value of GridViewDataComboBoxColumn in server side at GridViewUpdated event.
I want to manage permissions and access to a SQL Server database server on
So I have access to a dedicated server and want to finally create my
i want to access a integer and a string from a class to all
I want to make a business logic of server side Java application as a
I have something like that: <asp:ListView ID=lvList runat=server> <LayoutTemplate> <select id=select_list> <option value=-1> select
I am working on a project which requires a server side access to google

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.