TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aktham Mahmoud
NA
720
37.7k
Open Another page In bootstrap modal popup
Mar 23 2020 10:37 AM
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
Reply
Answers (
1
)
Printing POS from a webform
Store Page Element in db + architecture