UI confirmation not firing the event - javascript

I am using jQuery confirmation box within my listView and the confirmation box displayed with the user clicks delete.
The problem that I am faced with, is that when the user clicks OK it, the lvAlbums_ItemDeleting event is not fired.
Below is the .aspx code:
<link href="jQuery/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="jQuery/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
<script src="https://www.google.com/jsapi?key=" type="text/javascript"></script>
<script type="text/javascript">
google.load("jquery", "1");
google.load("jqueryui", "1");
</script>
<script type="text/javascript">
$().ready(function () {
$('#dialogContent').dialog({
autoOpen: false,
modal: true,
title: "MySql Membership Config Tool",
width: 300,
height: 250
});
});
function rowAction(uniqueID) {
$('#dialogContent').dialog('option', 'buttons',
{
"OK": function () { __doPostBack(uniqueID, ''); $(this).dialog("close"); },
"Cancel": function () { $(this).dialog("close"); }
});
$('#dialogContent').dialog('open');
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="thumbs">
<asp:ListView ID="lvAlbums" runat="server" GroupItemCount="15" DataKeyNames="album_id">
<LayoutTemplate>
<table id="groupPlaceholderContainer" runat="server" border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; width: 100%;">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<ItemTemplate>
<div>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "ThumbNail.ashx?ImURL=/uploads/"+Eval("photo_file_name") %>'
Width="130" Height="150" BorderStyle="None" />
<asp:Label ID="lblPhotoTitle" runat="server" Text='<%# Eval("album_name") %>' CssClass="photoTitle"></asp:Label>
<br />
<asp:Button ID="btnDeleteAlbum" runat="server" Text="Delete Album" Width="144px" OnClick="lvAlbums_ItemDeleting" OnClientClick="javascript:return rowAction(this.name);"
CommandName="Delete" />
</div>
</ItemTemplate>
</asp:ListView>
</div>
<div class="pager">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvAlbums" PageSize="12">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="true" ShowPreviousPageButton="true"
ShowLastPageButton="false" ShowNextPageButton="false" ButtonCssClass="first"
RenderNonBreakingSpacesBetweenControls="false" />
<asp:NumericPagerField CurrentPageLabelCssClass="current" NextPreviousButtonCssClass="next"
NumericButtonCssClass="numeric" ButtonCount="10" NextPageText=">" PreviousPageText="<"
RenderNonBreakingSpacesBetweenControls="false" />
<asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="false"
ShowLastPageButton="true" ShowNextPageButton="true" ButtonCssClass="last" RenderNonBreakingSpacesBetweenControls="false" />
</Fields>
</asp:DataPager>
</div>
</div>
<div id="dialogContent">
<h3>confirm</h3>
<p>Click ok to accept</p>
</div>
</form>
</body>
Firebug throws the following error:
__doPostBack is not defined
[Break On This Error] "OK": function () { __doPostBa...ID, ''); $(this).dialog("close"); },
If anyone could provide a solution with the above, it would be greatly appreciated.
I have spent days looking at different jQuery confirmation box examples but this is the best I can do. Ideally I would want to be use http://jqueryui.com/demos/dialog/#modal-confirmation within gridviews, dataViews and ListViews but can't find examples which exactly provide steps to follow.
Thanks

Or you could use this:
protected void Page_PreRender(object sender, EventArgs e)
{
//If the page doesn't have a control that causes a postback, __doPostBack() won't be output
//as a function definition. One way to override this is to include this line in your Page_PreRender():
Page.ClientScript.GetPostBackEventReference(this, string.Empty);
//This function returns a string calling __doPostBack(); but also forces the page to output
//the __doPostBack() function definition.
}

Related

ASP.Net WebForms not firing UI events from codebehind file

I have simple UI in aspx file, with aspx.cs codebehind. No matter what kind of control I use, events from this file wont fire - the only ones that are working are events like Init, PageLoad.
Events are created via designer.
What I tried:
Basic OnClick on markup page
OnClick in designer
Inline c# Code in markup page via javascript
PageMethods
Pure javascript click
Whole new page
When I add for example alert for click event in javascript, it works. But Im not able to run my c# code after user clicks on button.
I have also removed everything from file (validation, other controls...), but not even then my code works.
There are also no errors in console
Markup Page
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Views/Shared/Site.Master" EnableEventValidation="false" CodeBehind="Report.aspx.cs" Async="true" Inherits="App.Web.Views.Besparingen.Report" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content runat="server" ContentPlaceHolderID="Content" ID="Content1">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
<link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css" />
<script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('[id*=selectYear]').multiselect({
includeSelectAllOption: true
});
});
</script>
<script type="text/javascript">
$(function () {
$('[id*=selectPortfolio]').multiselect({
includeSelectAllOption: true
});
});
</script>
<script type="text/javascript">
$(function () {
$('[id*=selectSector]').multiselect({
includeSelectAllOption: true
});
});
</script>
<form runat="server" id="form">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" ScriptMode="Release" ClientIDMode="Static" ViewStateMode="Enabled">
</asp:ScriptManager>
<div style="margin: 10px;">
<asp:Label Style="margin-right: 40px;" ID="YearLabel" Text="Year:" runat="server" AssociatedControlID="selectYear"></asp:Label>
<asp:ListBox ID="selectYear" runat="server" DataValueField="Value" DataTextField="Text" SelectionMode="Multiple" CausesValidation="false"></asp:ListBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ForeColor="Red"
ControlToValidate="selectYear"
ValidationGroup="yearGroup"
ErrorMessage="Select year."
runat="server">
</asp:RequiredFieldValidator>
</div>
<div style="margin: 10px;">
<asp:Label Style="margin-right: 12px;" ID="PortfolioLabel" Text="Portfolio:" runat="server" AssociatedControlID="selectPortfolio"></asp:Label>
<asp:ListBox ID="selectPortfolio" runat="server" DataValueField="Value" DataTextField="Text" CausesValidation="false"></asp:ListBox>
</div>
<div style="margin: 10px;">
<asp:Label Style="margin-right: 25px;" ID="SectorLabel" Text="Sector:" runat="server" AssociatedControlID="selectSector"></asp:Label>
<asp:ListBox ID="selectSector" runat="server" DataValueField="Value" DataTextField="Text" CausesValidation="false"></asp:ListBox>
</div>
<div>
<asp:Button ID="reportButton" runat="server" OnClick="reportButton_Click" ClientIDMode="Static" Text="Create report" CausesValidation="true" ValidationGroup="yearGroup" />
</div>
<div style="margin-top: 40px;">
<rsweb:ReportViewer runat="server" ID="reporter" Width="100%" ClientIDMode="AutoID" ProcessingMode="Local" BackColor="White" BorderStyle="None" ToolBarItemBorderStyle="None" InternalBorderStyle="None" BorderColor="White" InternalBorderColor="White" ToolBarItemBorderColor="White" AsyncRendering="false"></rsweb:ReportViewer>
</div>
</form>
<script type="text/javascript">
$(document).ready(function () {
//$("#reportButton").click(function () {
// event.preventDefault();
// alert("Handler for .click() called.");
//});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Title" runat="server">
Besparingen
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ValidationSummary" runat="server">
</asp:Content>
Code Behind file
public partial class Report : System.Web.Mvc.ViewPage<model>
{
List<string> years = new List<string>();
string sector;
string portfolio;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
selectPortfolio.DataSource = Model.List[0].Portfolios;
selectPortfolio.DataBind();
selectYear.DataSource = Model.List[0].Years;
selectYear.DataBind();
selectSector.DataSource = Model.List[0].Sectors;
selectSector.DataBind();
}
}
protected void reportButton_Click(object sender, EventArgs e)
{
foreach (ListItem item in selectYear.Items)
{
if (item.Selected)
{
years.Add(item.Text);
}
}
sector = selectSector.SelectedItem?.Text ?? string.Empty;
portfolio = selectPortfolio.SelectedItem?.Text ?? string.Empty;
if (years.Count > 0)
{
BesparingenDS.DataTable1DataTable table = new BesparingenDS.DataTable1DataTable();
DataTable1TableAdapter adapter = new DataTable1TableAdapter();
adapter.Fill(table, sector, portfolio, string.Join(",", years));
ReportDataSource datasource = new ReportDataSource("DataSource", (DataTable)table);
System.Security.PermissionSet sec = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);
reporter.LocalReport.SetBasePermissionsForSandboxAppDomain(sec);
reporter.LocalReport.ReportPath = "Views\\Besparingen\\BesparingenReport.rdlc";
reporter.LocalReport.DataSources.Clear();
reporter.LocalReport.DataSources.Add(datasource);
reporter.LocalReport.Refresh();
reporter.DataBind();
}
}
}
Thank you for help and sorry for my bad english

Gridview not showing the records when i input the specific record name

hope you all are fine
i am new on asp.net i am facing a problem when i input the data in textbox and the result related to that textbox can not showing in gridview popup.
here is my code below
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$("#Button1").live("click", function () {
$("#popup").dialog({
title: "Displaying GridView Data",
width: 600,
buttons: {
// if you want close button use below code
// Close: function () {
// $(this).dialog('close');
// }
}
});
return false;
});
</script>
<div id="popup" style ="display:none">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="OpprId" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="CardCode" HeaderText="CardCode"
SortExpression="CardCode" />
<asp:BoundField DataField="OpprId" HeaderText="OpprId" ReadOnly="True"
SortExpression="OpprId" />
<asp:BoundField DataField="SlpCode" HeaderText="SlpCode"
SortExpression="SlpCode" />
<asp:BoundField DataField="PredDate" HeaderText="PredDate"
SortExpression="PredDate" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestDataBaseConnectionString %>"
SelectCommand="SELECT [CardCode], [OpprId], [SlpCode], [PredDate] FROM [OOPR] WHERE ([CardCode] = #CardCode)">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="CardCode" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</div>
</form>
</body>
Kindly help, your help will be highly appreciated
Thanks
Your code is kind of incomplete. I don't see the textbox1 control. Also You have gridview in a div which has "style=display:none";
Please share your complete code or enough code so someone can understand and help you out.
UPDATE
Add
$( "#popup" ).dialog({ autoOpen: false });
before the code
$("#Button1").live("click", function ()
Also remove the style on #popup div.
More details are here https://api.jqueryui.com/dialog/#entry-examples
Hope it should work.

Showing a dialog on button click

This is a part of my page:
<link href="scripts/jquery-ui.css" rel="stylesheet" />
<link href="scripts/jquery-ui.theme.css" rel="stylesheet" />
<script type="text/jscript" src="scripts/jquery.js"></script>
<script type="text/jscript" src="scripts/jquery-ui.js"></script>
<script type="text/jscript" src="scripts/jquery-2.1.1.min.js"></script>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data" method="post">
<div>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/HeaderBar.png" CssClass="header" />
<asp:Image ID="Image2" runat="server" ImageUrl="~/images/title.PNG" CssClass="Title" />
<img alt="" class="logo" src="Images/ECON_76px.png" />
<asp:Label ID="Label2" runat="server" CssClass="VersionText" Text="Version {0}"></asp:Label>
<asp:LinkButton ID="lbLogOff" runat="server" CssClass="lbLogOff" ToolTip="Close your current session">Log off</asp:LinkButton>
<asp:LinkButton ID="lbReset" runat="server" CssClass="lbReset" OnClientClick="ShowDialog();" ToolTip="Restart your session as if you would just have logged in">Restart</asp:LinkButton>
<asp:Label ID="lblTestDB" runat="server" CssClass="lblTestDB" Text="CONNECTED TO TEST DATABASE"></asp:Label>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" ViewStateMode="Enabled">
</asp:ContentPlaceHolder>
</div>
<div id="dialog" title="Restart">
<p>This will clear all data of the current session (as if you would have just logged in)!</p>
<p>Are you sure?</p>
<input id="yes" type="button" value="Yes" />
<input id="no" type="button" value="No" />
</div>
<script type="text/jscript">
function ShowDialog() {
$("#dialog").dialog({
buttons:
{
"Yes": function () { $("#dialog").dialog("close"); return false; }
, "No": function () { return true; }
}
}).prev().find(".ui-dialog-titlebar-close").hide();
}
</script>
</form>
</body>
The idea is to show a dialog when the restart button is clicked as I don't like the alert box of Chrome.
Why does it not work?
Kind of took it straight from an example in a book.
You aren't loading any jQuery UI CSS libraries, and you are loading 2 versions of normal jQuery. As a quick test, try removing your own jQuery libraries and link to Google to get you started. You can then gradually place yours back:
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
A side note, you are mixing type "jscript" and "javascript". As of HTML5, you can simply leave off specifying type declarations. It will be assumed to be CSS or JavaScript.
There it needs some changes in your code. Try this:
<script type="text/javascript">
$(document).ready(function(){
$("#dialog").dialog({
buttons:
{
"Yes": function () { $("#dialog").dialog("close"); return false; }
, "No": function () { return true; }
}
}).prev().find(".ui-dialog-titlebar-close").hide();
});
function ShowDialog() {
$("#dialog").dialog('open');
}
</script>

Asp .net validator without changing style

I have created a design using asp .net. On clicking the submit button a validator message will come but style is changed. I have seen that "required" keyword is used for showing validator message in php and it won't change any style. Is it possible to use such a validator in asp .net?
I have tried:
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControltoValidate"Control Name"></asp:RequiredFieldValidator>
But I need to show the error message as pop up.
You need to
Set ShowMessageBox="true" in your ValidationSummary control;
Set Display="none" in your RequiredFieldValidator control;
Example:
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControltoValidate"Control Name" Display="none" />
<asp:ValidationSummary ID="MyValidationSummary" runat="server"
ShowMessageBox="true"
ShowSummary="false" />
Based on your question, I believe you are looking for a validation example in ASP.net.
Please see the simple example I have for you below:
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.23/jquery-ui.min.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/Blitzer/jquery-ui.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript">
function WebForm_OnSubmit() {
if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) {
$("#validation_dialog").dialog({
title: "Validation Error!",
modal: true,
resizable: false,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
return false;
}
return true;
}
</script>
Name:
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Display="None" ControlToValidate="txtName"
runat="server" ErrorMessage="Name is required."></asp:RequiredFieldValidator>
<br />
Email:
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Display="None" ControlToValidate="txtEmail"
runat="server" ErrorMessage="Email is required."></asp:RequiredFieldValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<div id="validation_dialog" style="display: none">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</div>
</form>
</body>

Javascript function doesn't get textbox value (text) after selecting an item in gridview

I have 2 pages, Cart.aspx and SelectPartner.aspx. And a JavaScript file, popup.js
In Cart.aspx I have a button that opens the page SelectPartner.aspx (as a new window) by the InvokePop() function.
In SelectPartner.aspx I have a gridview (with Selection enabled), a textbox, and buttons Ok and Cancel. This is what I want to do: when I select an item in the gridview, the value of one column is shown in the textbox, and when when I press the button Ok the function ReturnPartner() is called and should close the this window (SelectPartner.aspx) and show the value of this textbox in another textbox in the Cart.aspx page. If I write something into the TextBox in SelectPartner.aspx I can pass that value to the TextBox in the Cart.aspx page, but when I press a select button in the gridview the value is not passed.
I don't know what happens, please help me...
Here is the code of Cart.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Cart.aspx.cs" Inherits="NMv01.Cart" %>
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
#Select1
{
height: 16px;
width: 24px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" src="popup.js"></script>
<asp:Label ID="lblPartnerId" runat="server" Text="ID del Socio"></asp:Label>
<br />
<asp:TextBox ID="txtPartnerID" runat="server"></asp:TextBox>
<asp:Button ID="btnPartnerId" runat="server" Text="Elegir Socio" />
</asp:Content>
Now SelectPartner.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="SelectPartner.aspx.cs" Inherits="NMv01.catalog.SelectPartner" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="popup.js"></script>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td>
</td>
<td>
<asp:GridView ID="grdSelectPartner" runat="server" AutoGenerateColumns="False"
AutoGenerateSelectButton="True" DataKeyNames="PartnerId"
DataSourceID="srcSelectPartner"
onselectedindexchanged="grdSelectPartner_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="PartnerName" HeaderText="PartnerName"
SortExpression="PartnerName" />
<asp:BoundField DataField="PartnerId" HeaderText="PartnerId" ReadOnly="True"
SortExpression="PartnerId" />
<asp:BoundField DataField="PartnerCity" HeaderText="PartnerCity"
SortExpression="PartnerCity" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="srcSelectPartner" runat="server"
ConnectionString="Data Source=ZUNIGA-PC\SQL1;Initial Catalog=NovamMonetanDB;User ID=sa; pwd=Next2011"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT [PartnerName], [PartnerId], [PartnerCity] FROM [Partners] ORDER BY [PartnerName]">
</asp:SqlDataSource>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="Label1" runat="server" Text="ID:"></asp:Label>
<asp:TextBox ID="txtPartner" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnOk" runat="server" Text="OK" OnClientClick="ReturnPartner()" />
<asp:Button ID="btnCancel" runat="server" Text="Cancelar" />
<br />
<br />
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
And this is the popup.js file:
function InvokePop(fname) {
val = document.getElementById(fname).value;
// to handle in IE 7.0
if (window.showModalDialog) {
retVal = window.showModalDialog("SelectPartner.aspx?Control1=" + fname, 'Choose Partner', "dialogHeight:360px,dialogWidth:360px,resizable:yes,center:yes,");
document.getElementById(fname).value = retVal;
}
// to handle in Firefox
else {
retVal = window.open("SelectPartner.aspx?Control1=" + fname, 'Choose Partner', 'height=360px,width=360px,resizable=yes,modal=yes');
retVal.focus();
}
}
function ReturnPartner() {
var returnString = document.getElementById('txtPartner').value;
RetrieveControl();
// to handle in IE 7.0
if (window.showModalDialog) {
window.returnValue = returnString;
window.close();
}
// to handle in Firefox
else {
if ((window.opener != null) && (!window.opener.closed)) {
// Access the control.
window.opener.document.getElementById(ctr[1]).value = returnString;
}
window.close();
}
}
function RetrieveControl() {
//Retrieve the query string
queryStr = window.location.search.substring(1);
//Retrieve the control passed via querystring
ctr = queryStr.split("=");
}
I would suggest you to remove the use of window.showModalDialog() and use window.open() instead because Window.open() is supported uniformly by all browsers while window.ShowModalDialog() is an MSIE feature only.
showModalDialog() is said to have trouble "posting back" for which a iframe hack is needed.
i tested your code with window.open for all browsers and it worked great.

Categories

Resources