Modal pop up wont show up regardless of what i do - c#

am currently trying to find a way to open up a modal box based on the rows in the table. however when i run the program and click the edit button, the modal wont show up. Here is a sample code:
Gridview:
<asp:Gridview CssClass=" table table-borderless" ID="PO_Form" runat="server" AutoGenerateColumns="false" OnRowCommand="PO_Form_RowCommand">
<Columns>
<asp:ButtonField Text="Edit" ControlStyle-CssClass="page-link" CommandName="EditForm"/>
<asp:BoundField DataField="PO_no" HeaderText="PO No." />
<asp:BoundField DataField="supplier_name" HeaderText="Supplier name" />
<asp:BoundField DataField="flight_no" HeaderText="Flight No." />
<asp:BoundField DataField="bkg_date" HeaderText="Booking Date" />
<asp:BoundField DataField="status" HeaderText="Status" />
</Columns>
<HeaderStyle BackColor="#666666" />
</asp:Gridview>
</div>
Modal:
<div id="editmodal" class="modal fade" role="dialog" >
<div class="modal-dialog">
<%-- Modal Content --%>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn btn-default" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
Test
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
back code:
protected void PO_Form_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "EditForm")
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Pop", "EditFormModal();", true);
}
}

Related

My Onclick Element in my LinkButton not triggered because of the modal(?)

so i use the same modal to create new and edit existing Studio Detail. when i want to edit existing, i click on the studio name on the table, get the data from DB, and insert it to textbox and change the button inside the modal as "Update" to update the record. but when i want to create new, it set the textbox inside the modal to empty, and change the button text to Save, but when i pun debug point at the OnClick function, it didn't triggered.
Modal:
<asp:UpdatePanel runat="server" ID="upDetailModal" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<div class="row">
<div class="col-7">
</div>
<div class="col-5">
<asp:LinkButton runat="server" ID="lbAddDetail" Text="Add Detail" CssClass="btn userButton" OnClick="lbAddDetail_Click" CausesValidation="false" data-bs-toggle="modal" data-bs-target="#detailModal"/>
</div>
</div>
</div>
<div id="modalDetail">
<div class="modal fade" id="detailModal" tabindex="-1" aria-labelledby="Studio Background" aria-hidden="true" >
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="detailTitle">Studio Background</h4>
</div>
<div class="modal-body">
<p>Studio Background Name</p>
<asp:TextBox runat="server" ID="txtStudioBackgroundName" CssClass="loginForm" />
<br />
<br />
<p>Studio Background Capacity</p>
<asp:TextBox runat="server" ID="txtStudioBackgroundCapacity" CssClass="loginForm" />
<br />
<br />
<p>Studio Package</p>
<asp:FileUpload runat="server" ID="fuStudioBackground" AllowMultiple="true" accept="image/png,image/jpeg" CssClass="loginForm" />
</div>
<div class="modal-footer">
<asp:LinkButton runat="server" ID="lbSaveDetail" CssClass="btn userButton" Text="Save" OnClick="lbSaveDetail_Click" />
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
protected void lbAddDetail_Click(object sender, EventArgs e)
{
idDetail = 0;
txtStudioBackgroundCapacity.Text = "";
txtStudioBackgroundName.Text = "";
lbSaveDetail.Text = "Save";
upDetailModal.Update();
showDetailModal();
}
I think the modal and the onClick function is clashed. i expect the onClick function to be triggered when i click the button

How can I select the record in the grid view and delete or edit this record? In Asp.Net Web Form

How can I select the record in the grid view and delete or edit this record? In Asp.Net Web Form
I want this to be done with the Bootstrap modal
I do this with Entity Framework
I have only been able to code to add
The methods I know for editing and deleting are not suitable for this project and they do not work on Bootstrap Modal
Html Code:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ProductControl.aspx.cs" Inherits="AppData.Pages.ProductControl" %>
<asp:Content ID="HeadContent" ContentPlaceHolderID="Head" runat="server">
<script src="../Scripts/jquery-3.6.0.slim.min.js"></script>
<script src="../Scripts/Site.js"></script>
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="container">
<div class="row">
<div class="col-md-12 table-responsive" id="ProductDiv">
<div class="d-flex justify-content-between align-items-center mb-3 mt-3">
<h4>List of Products</h4>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#ModalAdd">
Add Product
</button>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:GridView ID="GridView" runat="server" CssClass="table text-center table-bordered table-hover" HeaderStyle-CssClass="table-dark" AutoGenerateColumns="false" DataKeyNames="Id" OnRowCommand="GridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="" ItemStyle-Font-Size="Small">
<HeaderTemplate>Row</HeaderTemplate>
<ItemTemplate><%# Container.DataItemIndex+1 %></ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Price" HeaderText="Price" />
<asp:BoundField DataField="Type" HeaderText="Type" />
<asp:BoundField DataField="Barcode" HeaderText="Barcode" />
<asp:TemplateField HeaderText="Commands" ItemStyle-Font-Size="Small">
<ItemTemplate>
<asp:LinkButton CssClass="btn btn-warning" ID="BtnEdit" runat="server">Edit</asp:LinkButton>
<asp:LinkButton CssClass="btn btn-danger" ID="BtnDelete" runat="server" data-toggle="modal" data-target="#ModalDelete">Delete</asp:LinkButton>
<asp:LinkButton CssClass="btn btn-info" ID="BtnDetail" runat="server">Detail</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div class="row">
<asp:Label ID="LblNotFound" runat="server" Text="No Product Found" CssClass="col-12 alert alert-danger text-center" Visible="false"></asp:Label>
</div>
</div>
<!-- Modal Add -->
<asp:UpdatePanel ID="UpdatePanelModalAdd" runat="server">
<ContentTemplate>
<div class="modal" id="ModalAdd">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Add New Record</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-6">
<p>Name:</p>
<asp:TextBox ID="Name" placeholder="Name" runat="server" CssClass="form-control"></asp:TextBox>
</div>
<div class="col-6">
<p>Price:</p>
<asp:TextBox ID="Price" placeholder="Price" runat="server" CssClass="form-control"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-6">
<br />
<p>Type:</p>
<asp:TextBox ID="Type" placeholder="Type" runat="server" CssClass="form-control"></asp:TextBox>
</div>
<div class="col-6">
<br />
<p>Barcode:</p>
<asp:TextBox ID="Barcode" placeholder="Barcode" runat="server" CssClass="form-control"></asp:TextBox>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="BtnCreate" runat="server" CssClass="btn btn-success" Text="Create" OnClick="BtnCreate_Click" />
<asp:Button ID="BtnCancel" runat="server" CssClass="btn btn-danger" Text="Cancel" data-dismiss="modal" />
</div>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnCreate" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="BtnCancel" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<!-- Modal Detail -->
<asp:UpdatePanel ID="UpdatePanelModalDetail" runat="server">
<ContentTemplate>
<div class="modal" id="ModalDetail">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Detail Record</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-6">
<p>Name:</p>
<asp:Label ID="LblName" CssClass="text-secondary" runat="server" Text=""></asp:Label>
</div>
<div class="col-6">
<p>Price:</p>
<asp:Label ID="LblPrice" CssClass="text-secondary" runat="server" Text=""></asp:Label>
</div>
</div>
<div class="row">
<div class="col-6">
<br />
<p>Type:</p>
<asp:Label ID="LblType" CssClass="text-secondary" runat="server" Text=""></asp:Label>
</div>
<div class="col-6">
<br />
<p>Barcode:</p>
<asp:Label ID="LblBarcode" CssClass="text-secondary" runat="server" Text=""></asp:Label>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="Button1" runat="server" CssClass="btn btn-success" Text="Create" OnClick="BtnCreate_Click" />
<asp:Button ID="Button2" runat="server" CssClass="btn btn-danger" Text="Cancel" data-dismiss="modal" />
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<!-- Modal Delete -->
<asp:UpdatePanel ID="UpdatePanelModalDelete" runat="server">
<ContentTemplate>
<div class="modal" id="ModalDelete">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Delete Record</h4>
</div>
<div class="modal-body">
<h6 class="text-center">Are you sure you want to delete this record?</h6>
<br />
<div class="text-center">
<asp:Button ID="Delete" CssClass="btn btn-danger border-2 border-dark" runat="server" Text="Delete" CommandArgument='<%# Eval("Id") %>' CommandName="Delete" />
<button id="Cancel" class="btn btn-light border-2 border-dark" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Delete" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</asp:Content>
And Backend Code:
using AppData.Models;
using System;
using System.Collections.Generic;
using System.EnterpriseServices;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AppData.Pages
{
public partial class ProductControl : System.Web.UI.Page
{
Models.ProductDbEntities Db = new Models.ProductDbEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (GridView.Rows.Count > 0)
{
LblNotFound.Visible = false;
}
else
{
GridView.DataSource = Db.TblProducts.ToList();
GridView.DataBind();
}
}
protected void BtnCreate_Click(object sender, EventArgs e)
{
TblProduct Row = new TblProduct();
Row.Name = Name.Text;
Row.Price = Price.Text;
Row.Type = Type.Text;
Row.Barcode = Convert.ToInt64(Barcode.Text);
Db.TblProducts.Add(Row);
Db.SaveChanges();
Response.Redirect("ProductControl.aspx");
}
protected void BtnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("Pages/ProductControl.aspx");
}
protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
var id = e.CommandArgument;
if (e.CommandName == "Delete")
{
Int64 Id = Convert.ToInt64(id);
var Row = Db.TblProducts.FirstOrDefault(n => n.Id == Id);
Db.TblProducts.Remove(Row);
Db.SaveChanges();
Response.Redirect("DataControl.aspx");
GridView.DataSource = Db.TblProducts.ToList();
GridView.DataBind();
}
}
}
}
I understand your approach, but if you are using bootstrap modals you need to write a little bit more code.
One way to achieve this is by following the next steps:
In the Delete modal add a hidden field to hold the selected productId and an event handler for the delete button:
<div class="modal-body">
<h6 class="text-center">Are you sure you want to delete this record?</h6>
<br />
<!--add this inside delete modal -->
<input type="hidden" id="productIdToDelete" runat="server" />
<div class="text-center">
<!-- remove CommandArgument and CommandName from the Delete button. They are useless in the popup. -->
<!-- add an event handler to OnClick-->
<asp:Button ID="Delete" CssClass="btn btn-danger border-2 border-dark" runat="server" Text="Delete" OnClick="BtnDelete_Click" />
...
Create event handlers for when the modal is opened in order to propagate the productId from the current row in the grid to the modal:
<script src="../Scripts/Site.js"></script>
<script type="text/javascript">
$(document).ready(
function () {
//use a jquery selector to assign an event handler to all Delete Buttons found on the page (nottice they all start with the same prexif)
$("[id*=MainContent_GridView_BtnDelete]").click(function () {
//get the id of the product from the selected row first cell and assign it to the hidden field in the modal
$("#MainContent_productIdToDelete").val($(this).closest('tr').find('td').eq(0).html());
});
});
</script>
Finally, handle the delete event in the code behind:
protected void BtnDelete_Click(object sender, EventArgs e)
{
string idVal = Request.Form[productIdToDelete.UniqueID];
var id = Convert.ToInt64(idVal);
// implement delete logic ...
}
Use the same approach for Edit. (Look at this example.)

How to use Gridview Paging in modal popup window ASP.NET Bootstrap 4.0

Need Suggestions, why paging is not working correctly or event fire up but popup page are not refreshed correctly.
I made a User Control with Bootstrap modal content and a GridView.
ASP Page (Control):
<asp:Panel runat="server" ID="pModal">
<div class="modal fade" id="searchDiv" role="dialog" aria-labelledby="Adresse wählen:" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<asp:UpdatePanel ID="upModal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<asp:GridView ID="gvSearch" runat="server" CssClass="table table-hover table-responsive-sm table-sm table-bordered" AllowPaging="True" AllowSorting="true"
PageSize="5" AutoGenerateColumns="true" ShowHeaderWhenEmpty="true"
OnPageIndexChanging="gvSearch_PageIndexChanging" PagerSettings-PageButtonCount="5">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnGvOK" runat="server" Text="OK" CssClass="btn btn-dark" OnClick="btnGvOK_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings PageButtonCount="5" />
<PagerStyle CssClass="pagination" HorizontalAlign="Justify" />
</asp:GridView>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
With this script I show the popup:
public void LoadUC(DataTable dt)
{
dtSource = dt;
if (dtSource.Rows.Count > 0)
{
LoadSearchGridView();
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Script",
"<script> $('#searchDiv').modal('show'); </script>", false);
upModal.Update();
}
}
So I change the page:
protected void gvSearch_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvSearch.PageIndex = e.NewPageIndex;
LoadSearchGridView();
upModal.Update();
}
When I am changing the page I obtain that:
How to solve that?
Thanks in advance.
I found the problem. First time I show this window with function LoadUC with DataTable parameter but when I am changing the page I call LoadSearchGridView() function without to send again the DataTable (DataSource for GridView) and the DataSource alredy is null.
Now I'm sending always the DataTable for DataSource and pagination works perfect.
Thanks for all. :)

GridView - Client Side "WHERE" clause in the SqlDataSource?

I have a GridView with a TemplateField containing a button. This button opens up a modal window which contains another GridView as seen below:
Template Field in Gridview1:
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnOpen" runat="server" Text="Show Gridview" OnClick="btnOpen_Click" data-toggle="modal" data-target="#myModal"/>
</ItemTemplate>
Modal Window:
<div class="modal" id="idModal">
<div class="container">
<div class="modal-header">
<h1>Transaction Details<a class="close-modal" href="#">×</a></h1>
</div>
<div class="modal-body">
<asp:GridView ID="gvDetail" runat="server" AutoGenerateColumns="false" DataSourceID="SqlgvDetail"
OnRowDataBound="gvDetail_RowDataBound" CssClass="table table-hover table-bordered" EmptyDataText="No data to display.">
<Columns>
<asp:BoundField DataField="metalid" HeaderText="Metal ID"/>
<asp:BoundField DataField="enddate" HeaderText="End Date" DataFormatString="{0:dd-MM-yyyy}" />
<asp:BoundField DataField="startdate" HeaderText="Start Date" DataFormatString="{0:dd-MM-yyyy}" />
<asp:BoundField DataField="clientref" HeaderText="Client Ref" />
<asp:BoundField DataField="quantity" HeaderText="Quantity" DataFormatString="{0:N2}" />
</Columns>
</asp:GridView>
</div>
<div class="modal-footer">
<asp:Button ID="btn_close" runat="server" Text="OK" CssClass="close-modal btn-sm btn-primary"/>
</div>
</div>
</div>
<div class="modal-backdrop"></div>
GridView2 SqlDataSource:
<asp:SqlDataSource ID="SqlgvDetail" runat="server" ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>"
SelectCommand="SELECT td.metalid , td.enddate , td.startdate , td.clientref , td.quantity FROM trxdetail td">
</asp:SqlDataSource>
Now this code works fine and opens up the modal window with the SelectCommand as expected. However, I need to add a where clause based on a row value from GridView1. E.g. ...WHERE td.clientref = GridView1.SelectedRow.Cells[0].Text
Help please!
Edit: Modal Window:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<asp:GridView ID="gvDetail" runat="server" AutoGenerateColumns="false" DataSourceID="SqlgvDetail"
OnRowDataBound="gvDetail_RowDataBound" CssClass="table table-hover table-bordered" EmptyDataText="No data to display.">
<Columns>
<asp:BoundField DataField="metalid" HeaderText="Metal ID"/>
<asp:BoundField DataField="enddate" HeaderText="End Date" DataFormatString="{0:dd-MM-yyyy}" />
<asp:BoundField DataField="startdate" HeaderText="Start Date" DataFormatString="{0:dd-MM-yyyy}" />
<asp:BoundField DataField="clientref" HeaderText="Client Ref" />
<asp:BoundField DataField="quantity" HeaderText="Quantity" DataFormatString="{0:N2}" />
</Columns>
</asp:GridView>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Modal JS:
$(document).ready(function () {
$("#btnOpen").click(function () {
$("#myModal").modal();
});
});
You can actually set an <asp:ControlParameter> to the SelectedValue of a GridView. I think this is what you are looking for. As the documentation says:
As a further shortcut, you can directly determine the data key value of the first key field of the selected row by using the SelectedValue property.
So what you can do is set the DataKeyNames value on GridView1 to whatever value it is that you want to use in the WHERE clause.
<asp:GridView ID="GridView1" runat="server" DataKeyNames="clientref"
...
</asp:GridView>
Then set that as the control parameter in your SqlDataSource.
<asp:SqlDataSource ID="SqlgvDetail" runat="server"
ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>"
SelectCommand="SELECT td.metalid, td.enddate, td.startdate, td.clientref , td.quantity
FROM trxdetail td
WHERE clientref=#clientref">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1"
PropertyName="SelectedValue"
Name="clientref"
Type="Whatever type clientref is" />
</SelectParameters>
</asp:SqlDataSource>
Just remember you need to make sure the row in GridView1 is actually marked as the SelectedRow. You can do this in your button click event.
protected void btnOpen_Click(object sender, EventArgs e)
{
// Find the index to select
Button btnOpen = (Button)sender;
GridViewRow row = (GridViewRow)btnOpen.NamingContainer;
int selectedIndex = row.DataItemIndex;
// Set the selected index of the GridView
GridView1.SelectedIndex = selectedIndex;
// Bind the detail GridView now that the row is selected so
// that its SqlDataSource can get a SelectedValue for the
// parent GridView
gvDetail.DataBind();
}

Refresh a jquery pop up after closed a pop up window

I have modal pop up after clicking an asp button :
<div class="form-group">
<asp:Button ID="btnBrand" runat="server" Text="Add brand" CssClass="btn btn-info" OnClick="btnAdd_Click" />
</div>
Code Behind :
protected void btnAdd_Click(object sender, EventArgs e) //Open Model popup
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(#"<script type='text/javascript'>");
sb.Append("$('#addModal').modal('show');");
sb.Append(#"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddShowModalScript", sb.ToString(), false);
}
My popup modal html :
<div id="addModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="addModalLabel">Add brand details</h3>
</div>
<asp:UpdatePanel ID="updAdd" runat="server">
<ContentTemplate>
<div class="modal-body">
<div class="form-horizontal">
<div class="form-group" title="Code">
<div class="input-group FullWidth ">
<label for="Code" class="col-sm-2 control-label">Code</label>
<div class="col-sm-10">
<asp:TextBox ID="txtCodeAdd" runat="server" CssClass="form-control" MaxLength="10" onchange="OnTextChanged()" ToolTip="Colour Code" ValidationGroup="Save"></asp:TextBox>
</div>
</div>
</div>
<div class="form-group" title="Vendor">
<div class="input-group FullWidth">
<label for="Code" class="col-sm-2 control-label">Vendor</label>
<div class="col-sm-5">
<asp:TextBox ID="txtVendorAdd" runat="server" MaxLength="20" CssClass="form-control" ToolTip="Vendor" ReadOnly="true"></asp:TextBox>
</div>
<div class="col-sm-5 row form-inline">
<asp:Button ID="btnLookup" runat="server" Text="Lookup" CssClass="btn btn-info" OnClientClick="openLookup()" />
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddRecord" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
</div>
In this popup modal will trigger new window look-up page, my apsx lookup page as below :
<asp:UpdatePanel ID="upVendorLookup" runat="server">
<ContentTemplate>
<asp:GridView ID="grdVendor" runat="server" Width="100%" HorizontalAlign="Center"
AutoGenerateColumns="false" AllowPaging="True"
DataKeyNames="ID" CssClass="table table-condensed" GridLines="None"
OnPageIndexChanging="grdVendorPageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<input name="rdVendor" type="radio" value='<%# Eval("ID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="Code" HeaderText="Code" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Tel1" HeaderText="Tel#1" />
<asp:BoundField DataField="Tel2" HeaderText="Tel#2" />
</Columns>
</asp:GridView>
<asp:Button ID="btnSelect" runat="server" Text="Select" CssClass="btn btn-info" OnClick="btnSelectVendor" />
</ContentTemplate>
</asp:UpdatePanel>
Code behind :
protected void btnSelectVendor(object sender, EventArgs e)
{
string selectedValue = Request.Form["rdVendor"];
HttpContext.Current.Items["rdVendor"] = selectedValue;
Server.Transfer("../CodeEntry/Brand.aspx");
}
How do pass back the selected vendorID back to the brand.aspx and refreshing the pop up modal then set the vendorID value to the textbox in the popup modal ? And also closed the pop window..
Does it possible to implement in this way ?
I am now using HttpContext and able to get the vendorID in the pageload function from brand.aspx but unable to set the vendorID to the popup modal..
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string test = (String)HttpContext.Current.Items["rdVendor"];
txtVendorAdd.Text = test;
}
}
Any idea ?
If you fire up a modal popup using the below approach it would give you complete control on passing values between parent and popup.
http://02e34b5.netsolhost.com/youtube/Zpopup.aspx

Categories

Resources