C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Base Blockchain
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
1
Answer
Open Another page In bootstrap modal popup
Aktham Mahmoud
5y
6k
1
Reply
Greeting all
In my web application
I designed shopping cart in sperated aspx page.
when a user select a product and add to basket, a selecrted product added to basket successfully and redirect him to basket page.
I havent problem if redirect or not.
I am tring to show a baket aspx page as bootstrap modal popup.
am tring a video link to designe a basket
https://www.youtube.com/watch?v=Xb_4nWR2CMI
and I followed many ways to call a aspx page as modal popup but no way..
See Code below:
(1)
userbasket.aspx
<%@ Page Title=
""
Language=
"C#"
MasterPageFile=
"~/Site1.Master"
AutoEventWireup=
"true"
CodeBehind=
"userbasket.aspx.cs"
Inherits=
"WebApplication1.userbaasket"
%>
<asp:Content ID=
"Content2"
ContentPlaceHolderID=
"ContentPlaceHolder1"
runat=
"server"
>
<div id=
"myModal"
class
=
"modal fade"
>
<div
class
=
"modal-dialog"
>
<div
class
=
"modal-content"
>
<div
class
=
"modal-header"
>
<button type=
"button"
class
=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>×</button>
<h4
class
=
"modal-title"
>Article
for
C# Corner</h4>
</div>
<div
class
=
"modal-body"
style=
"overflow-y: scroll; max-height: 85%; margin-top: 50px; margin-bottom: 50px;"
>
<asp:Label ID=
"lblmessage"
runat=
"server"
ClientIDMode=
"Static"
></asp:Label>
<asp:Label ID=
"Lb_Cbasket"
runat=
"server"
Text=
""
></asp:Label>
<br />
<asp:GridView ID=
"Gvusrbasket"
runat=
"server"
AutoGenerateColumns=
"False"
EmptyDataText=
"Sorry! No Items Added to your basket."
>
<Columns>
<asp:TemplateField HeaderText=
"S_No"
>
<ItemTemplate>
<asp:Label ID=
"Label1"
runat=
"server"
Text=
'<%#Eval("Id") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Product Code"
>
<ItemTemplate>
<asp:Label ID=
"Label2"
runat=
"server"
Text=
'<%#Eval("Pro_CodeId") %>'
></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign=
"Center"
/>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Name"
>
<ItemTemplate>
<asp:Label ID=
"Label3"
runat=
"server"
Text=
'<%#Eval("P_Name") %>'
></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign=
"Center"
/>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Price"
>
<ItemTemplate>
<asp:Label ID=
"Label4"
runat=
"server"
Text=
'<%#Eval("P_Price") %>'
></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign=
"Center"
/>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<div
class
=
"col-2 col-sm-2 col-md-2 text-right"
>
<button type=
"button"
class
=
"btn btn-outline-danger btn-xs"
>
<i
class
=
"fa fa-trash"
aria-hidden=
"true"
></i>
</button>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:HyperLink ID=
"cshc"
runat=
"server"
Text=
"Continoue Shopping"
CssClass=
"btn-outline-warning"
></asp:HyperLink>
</div>
<div
class
=
"modal-footer"
>
<button type=
"button"
class
=
"btn btn-default"
data-dismiss=
"modal"
>Close</button>
</div>
</div>
</div>
</div>
</asp:Content>
(2)
userbasket.aspx c# code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Data.SqlClient;
using
System.Web.Configuration;
using
System.Web.Security;
namespace
WebApplication1
{
public
partial
class
userbaasket : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
DataTable dt =
new
DataTable();
DataRow dr;
dt.Columns.Add(
"Id"
);
dt.Columns.Add(
"Pro_CodeId"
);
dt.Columns.Add(
"P_Name"
);
dt.Columns.Add(
"P_Price"
);
dt.Columns.Add(
"cost"
);
dt.Columns.Add(
"totalcost"
);
if
(Request.QueryString[
"id"
] !=
null
)
{
if
(Session[
"bskitems"
] ==
null
)
{
dr = dt.NewRow();
//String mycon = "Data Source=HP-PC\\SQLEXPRESS;Initial Catalog=haritiShopping;Integrated Security=True";
string
mycon = @
"Data Source=(local)\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DbCh.mdf;Integrated Security=True"
;
SqlConnection scon =
new
SqlConnection(mycon);
String myquery =
"select * from Products where Id="
+ Request.QueryString[
"id"
];
SqlCommand cmd =
new
SqlCommand();
cmd.CommandText = myquery;
cmd.Connection = scon;
SqlDataAdapter da =
new
SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds =
new
DataSet();
da.Fill(ds);
dr[
"Id"
] = 1;
dr[
"Pro_CodeId"
] = ds.Tables[0].Rows[0][
"Pro_CodeId"
].ToString();
dr[
"P_Name"
] = ds.Tables[0].Rows[0][
"P_Name"
].ToString();
dr[
"P_Price"
] = ds.Tables[0].Rows[0][
"P_Price"
].ToString();
dt.Rows.Add(dr);
Gvusrbasket.DataSource = dt;
Gvusrbasket.DataBind();
Session[
"bskitems"
] = dt;
}
else
{
dt = (DataTable)Session[
"bskitems"
];
int
sr;
sr = dt.Rows.Count;
dr = dt.NewRow();
string
mycon = @
"Data Source=(local)\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DbCh.mdf;Integrated Security=True"
;
SqlConnection scon =
new
SqlConnection(mycon);
String myquery =
"select * from Products where Id="
+ Request.QueryString[
"id"
];
SqlCommand cmd =
new
SqlCommand();
cmd.CommandText = myquery;
cmd.Connection = scon;
SqlDataAdapter da =
new
SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds =
new
DataSet();
da.Fill(ds);
dr[
"Id"
] = sr + 1;
dr[
"Pro_CodeId"
] = ds.Tables[0].Rows[0][
"Pro_CodeId"
].ToString();
dr[
"P_Name"
] = ds.Tables[0].Rows[0][
"P_Name"
].ToString();
dr[
"P_Price"
] = ds.Tables[0].Rows[0][
"P_Price"
].ToString();
dt.Rows.Add(dr);
Gvusrbasket.DataSource = dt;
Gvusrbasket.DataBind();
Session[
"bskitems"
] = dt;
}
}
else
{
dt = (DataTable)Session[
"bskitems"
];
Gvusrbasket.DataSource = dt;
Gvusrbasket.DataBind();
}
}
}
}
}
(3)
Products page
<asp:ListView ID=
"ListView1"
runat=
"server"
DataSourceID=
"SDS_Pro"
DataKeyNames=
"Id"
GroupItemCount=
"4"
GroupPlaceholderID=
"groupPlaceHolder1"
ItemPlaceholderID=
"itemPlaceHolder1"
OnItemCommand=
"ListView1_ItemCommand"
>
<EmptyDataTemplate>
<table id=
"Table1"
runat=
"server"
style=
""
>
<tr>
<td><p style=
"color:red; font-size:medium"
>Sorry! No Products avialabe
in
selected Category to show it, Maybe under price modifying Or update Content..</p><br /><asp:HyperLink runat=
"server"
ID=
"HYBback"
Text=
"Back To Categories Page"
NavigateUrl=
"~/categories.aspx"
CssClass=
"btn-outline-warning"
></asp:HyperLink></td>
</tr>
</table>
</EmptyDataTemplate>
<LayoutTemplate>
<div
class
=
"row text-center"
>
<asp:PlaceHolder runat=
"server"
ID=
"groupPlaceHolder1"
></asp:PlaceHolder>
</div>
</LayoutTemplate>
<GroupTemplate>
<div
class
=
"row text-center screenwidth"
>
<asp:PlaceHolder runat=
"server"
ID=
"itemPlaceHolder1"
></asp:PlaceHolder>
</div>
</GroupTemplate>
<ItemTemplate>
<div
class
=
"col-lg-3 d-flex align-items-stretch"
>
<div
class
=
"card"
>
<div
class
=
"card-header"
style=
"font-size:x-large;color:brown"
>
<asp:Label ID=
"Label3"
runat=
"server"
Text=
'<%#Eval("P_Name")%>'
></asp:Label>
</div>
<div
class
=
"card-body"
>
<asp:Image ID=
"Image1"
runat=
"server"
ImageUrl=
'<%#Eval("P_photo") %>'
class
=
"rounded-circle"
Height=
"100%"
Width=
"100%"
/> <br />
Product Code: <%# Eval(
"Pro_CodeId"
) %> <br />
<p
class
=
"dsc"
><%#Eval(
"Ingredients"
) %></p>
<br />
Price:
<asp:Label ID=
"Label1"
runat=
"server"
Text=
'<%# Eval("P_Price") %>'
/><br />
Quatity: <asp:DropDownList ID=
"DDR_Q"
runat=
"server"
CssClass=
"dropdown-menu"
>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
</asp:DropDownList>
</div>
<div
class
=
"card-footer"
>
<asp:LinkButton ID=
"LinkButton1"
runat=
"server"
Text=
"Order Me :)"
CommandName=
"addtocart"
CommandArgument=
'<%#Eval("Id") %>'
></asp:LinkButton>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
As you can see
<asp:LinkButton ID="LinkButton1" runat="server" Text="Order Me :)" CommandName="addtocart" CommandArgument='<%#Eval("Id") %>' ></asp:LinkButton>
So how to add
href="#myModal" data-toggle="modal"
Like that sample
Open Another Gridview in Pop-up using Bootstrap Modal Pop-up
https://www.c-sharpcorner.com/UploadFile/77a82c/open-another-gridview-in-pop-up-using-bootstrap-modal-pop-up/
Nothing success with me,,
any help please
Thanks
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Printing POS from a webform
Store Page Element in db + architecture