I want to display modal popup on click of link button in grid view. below is the code but not displaying modal but the page refreshes.
------------------------------------------------------------
HTML
------------------------------------------------------------
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin_Master.Master" AutoEventWireup="true" CodeBehind="Search_Product.aspx.cs" Inherits="WhizCraft.Admin.Seearch_Product" %>
.icon-resize
{
font-size:20px;
color:#d95459;
}
function openModal() {
$('[id*=myModal').modal('show');
}
<%--
Enter Product Name
CssClass="table table-bordered" AutoGenerateColumns="False"
PagerSettings-Mode="Numeric" onrowdeleting="ProductGridView_RowDeleting" >
<%-- --%>
Image
<%--
--%>
C#
-----------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace WhizCraft.Admin
{
public partial class Seearch_Product : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["WhizcraftDBConnect"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadProducts();
}
}
private void LoadProducts()
{
try
{
DataTable dt;
using (SqlCommand cmd = new SqlCommand("GetProducts", con))
{
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataAdapter ad = new SqlDataAdapter(cmd))
{
dt = new DataTable();
ad.Fill(dt);
}
ProductGridView.DataSource = dt;
ProductGridView.DataBind();
}
}
catch (Exception ex)
{
throw;
}
}
protected void ProductGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
LinkButton lnkDelete = (LinkButton)ProductGridView.Rows[e.RowIndex].FindControl("lnkDelete");
using (SqlCommand cmd = new SqlCommand("DELETE FROM tblProduct WHERE PID=@PID", con))
{
cmd.Parameters.AddWithValue("@PID", Convert.ToInt32(lnkDelete.CommandArgument));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
LoadProducts();
}
protected void ViewImage(object sender, EventArgs e)
{
LinkButton lnkView = sender as LinkButton;
ProductImg.ImageUrl = lnkView.CommandArgument.ToString();
ClientScript.RegisterStartupScript(this.GetType(), "Pop", "openModal();", true);
}
}
}
-------------------------------------------------------------------------------------------------------
9 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Laxmidhar SahooPosted Oct 29, 2018, 4:01 AM
Akash PatelPosted Oct 29, 2018, 3:23 AM
Laxmidhar SahooPosted Oct 29, 2018, 3:02 AM
Akash PatelPosted Oct 29, 2018, 12:48 AM
Laxmidhar SahooPosted Oct 28, 2018, 10:27 PM
Akash PatelPosted Oct 28, 2018, 9:39 PM
Laxmidhar SahooPosted Oct 28, 2018, 12:45 AM
Akash PatelPosted Oct 27, 2018, 3:56 AM
Laxmidhar SahooPosted Oct 26, 2018, 11:59 PM