Why code behind C# button_clicked function doesn't call Javascript function? - c#

I want to test the C# code side when user click the button, the method in C# function should be able to call the JavaScript function to show alert C# public variable results. Somehow it doesn't call anything at all. At the bottom of ButtonRequest_Click function, I wrote Page.ClientScript.RegisterStartupScript(this.GetType(), "CreateIsm();", "CreateIsm();", true); to call CreateIsm(); function in JavaScript. Maybe this doesn't work?
Here is C# codes,
public Collection<PSObject> output = new Collection<PSObject>();
public string deviceName = "";
public string ipAddresses = "";
public string YourScript = "";
protected void ButtonRequest_Click(object sender, EventArgs e)
{
deviceName = string.Empty;
ipAddresses = string.Empty;
HiddenName.Visible = false;
string str = "";
string ipAddress = "";
string name = "";
var tbids = (List<string>)Session["tbids"];
//create a powershell
Runspace runSpace = RunspaceFactory.CreateRunspace();
runSpace.Open();
RunspaceInvoke invoke = new RunspaceInvoke();
Pipeline pipeline = runSpace.CreatePipeline();
Command invokeScript = new Command("Invoke-Command");
//Add powershell script file and arguments into scriptblock
ScriptBlock sb = invoke.Invoke(#"{D:\Scripts\Get-FreeAddress.ps1 '" + DropDownListContainer.SelectedValue + "' " + DropDownListIP.SelectedValue + "}")[0].BaseObject as ScriptBlock;
invokeScript.Parameters.Add("scriptBlock", sb);
invokeScript.Parameters.Add("computername", TextBoxServer.Text);
pipeline.Commands.Add(invokeScript);
Collection<PSObject> output = pipeline.Invoke();
runSpace.Close();
Runspace runSpace2 = RunspaceFactory.CreateRunspace();
runSpace2.Open();
foreach(PSObject psObject in output)
{
ipAddress = "" + psObject;
ipAddresses += "" + psObject;
foreach(var id in tbids)
try
{
name = Request[id];
deviceName += Request[id] + "\r\n";
Pipeline pipeline2 = runSpace2.CreatePipeline();
Command invokeScript2 = new Command("Invoke-Command");
//Add powershell script file and arguments into scriptblock
ScriptBlock sb2 = invoke.Invoke(#"{D:\Scripts\Set-IPAddress.ps1 " + ipAddress + " " + name + "}")[0].BaseObject as ScriptBlock;
invokeScript2.Parameters.Add("scriptBlock", sb2);
invokeScript2.Parameters.Add("computername", TextBoxServer.Text);
pipeline2.Commands.Add(invokeScript2);
tbids.RemoveAt(0);
Collection<PSObject> output2 = pipeline2.Invoke();
foreach(PSObject psObject2 in output2)
{
str = str + psObject2;
}
break;
}
catch
{
}
}
Page.ClientScript.RegisterStartupScript(this.GetType(), "CreateIsm();", "CreateIsm();", true);
}
Javascript on aspx side in html,
<%# Page Title="Home Page" Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" CodeBehind="~/Default.aspx.cs" Inherits="_Default" %>
<!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 id="Head1" runat="server">
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js" type="text/javascript"></script>
<script>
CreateIsm = function (funct) {
alert('<%=ipAddresses%>');
alert('<%=deviceName%>');
};
</script>
</head>
<body>
<form id="form1" runat="server">
//the are html codes here but I cut it off except ButtonRequest
<asp:Button ID="ButtonRequest" runat="server" Text="Request" Visible="False"
onclick="ButtonRequest_Click" />
</form>
</body>
</html>

Read this: http://msdn.microsoft.com/en-us/library/3hc29e2a(v=vs.100).ASPX
You can use OnClientClick like this:
<asp:button id="Button1" runat="server" OnClientClick="return confirm('Ok to post?')" onclick="Button1_Click" Text="Click!" />

Related

ASP.NET MVC IFrame webform CrystalReportViewer

This issue has been bugging me for a few hours. I have an MVC View(Report.cshtml) with an iframe in it. I set the src of the iframe dynamically by passing in the model.
I have a webform(ReportViewer.aspx) which has a crystalreportviewer in it. I pass in the the reportname and parameters as part of query string to this webform.
ControllerCode:
[HttpPost]
[Authorize]
public ActionResult ViewReport(ReportInfoViewModel _model)
{
string _parameterList = "";
ReportViewerViewModel _rptObj = new ReportViewerViewModel();
string[] _selected = {"0021", "2000", "0387"};
string subParam = "plazaparam=";
subParam += String.Join(",", _selected);
_parameterList = string.Concat(_parameterList, "#usrplazaparam=", String.Join(",", _selected));
string _reportSubPath = _model.report_path.Replace("\\", "/");
string _reportPath = string.Concat("~/Content/Reports", _reportSubPath.Trim());
string content = Url.Content(string.Format("~/CrystalReports/ReportViewer/ReportViewerForm.aspx?ReportName={0}&Parameters={1}", _reportPath, _parameterList));
_rptObj.ReportViewerPath = content;
return View("Report", _rptObj);
}
Report.cshtml:
#{
ViewBag.Title = "Report";
Layout = "~/Views/Shared/_rootLayout.cshtml";
}
#model CSC.ViewModels.ReportViewerViewModel
<iframe src="#Model.ReportViewerPath" style="width:100%; height:100%; border:none;"></iframe>
ReportViewer.aspx:
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Views/Shared/ReportSite.Master" CodeBehind="ReportViewerForm.aspx.cs" Inherits="CSC.CrystalReports.ReportViewer.ReportViewerForm" %>
<%# Register Assembly="CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" HasCrystalLogo="False" AutoDataBind ="false" Height="100%" EnableParameterPrompt="false" EnableDatabaseLogonPrompt="false" ToolPanelWidth="200px"
Width="100%" ToolPanelView="None"/>
</asp:Content>
ReportViewer.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["ReportDocument"] != null)
{
//ClientScript.RegisterStartupScript(this.GetType(), "IF", "alert('" + "Session Varialbe != null" + "');", true);
ReportDocument doc = (ReportDocument)Session["ReportDocument"];
CrystalReportViewer1.ReportSource = null;
CrystalReportViewer1.ReportSource = doc;
}
else
{
string reportPath = Request.QueryString["ReportName"];
string parameters = Request.QueryString["Parameters"];
this.objReport = null;
Session.Remove("ReportDocument");
this.objReport = new ReportDocument();
//ClientScript.RegisterStartupScript(this.GetType(), "Parameters", "alert('" + parameters + "');", true);
LoadReport(reportPath, parameters);
}
}
On Index.cshtml's page submit to ReportsController's ViewReport action, I pass in a dynamically constructed query string "ReportViewer.aspx?ReportName={reportName}&Parameters={parameterString}" to the iframe's src. This code should dynamically load the report specified in the query string dynamically(crystalreportviewer) and show the page. What is happening is that the same report is being loaded and displayed in the new page. I am not sure what I am doing wrong.
I would appreciate if somebody could point me in the right direction.
Thank you for your help
NH

SignalR Page Refresh Makes Multiple Connection

I want to show some live random data on client using SignalR.
Problem Is whenever I refresh the page it creates one more connection
and shows multiple data.
Mostly I think my approach is wrong.
So what I have done.
Step 1: Installed SignalR Using Nuget Install-Package Microsoft.AspNet.SignalR
Step 2: Made changes in Startup.cs File as follows.
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
app.MapSignalR(); //Added this line for SignalR
}
}
Step 3: Created Hub Class. "ServerStatisticsHub.cs"
public class ServerStatisticsHub : Hub
{
public void ServerParameter()
{
Random r = new Random();
int p = 0;
int m = 0;
int s = 0;
while(true) //May be this is the foolish thing I'm doing
{
p = r.Next(0, 100);
m = r.Next(0, 100);
s = r.Next(0, 100);
Clients.All.broadcastServerStatistics("{\"processor\":" + p + ", \"memory\":" + m + ", \"storage\":" + s + "}");
System.Threading.Thread.Sleep(2000);
}
}
}
Step 4: Created an View in Home "ServerState.cshtml".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<title>TestSignalR</title>
</head>
<body>
<div id="serverProcessor"></div>
<div id="serverMemory"></div>
<div id="serverStorage"></div>
<script src="#Url.Content("~/Scripts/jquery-2.2.3.min.js")"></script>
<script src="#Url.Content("~/Scripts/jquery.signalR-2.2.1.min.js")"></script>
<script src="#Url.Content("~/signalr/hubs")"></script>
<script>
$(function () {
// Reference the auto-generated proxy for the hub.
var serverStatistics = $.connection.serverStatisticsHub;
// Create a function that the hub can call back to display messages.
serverStatistics.client.broadcastServerStatistics = function (serverStat) {
var serverStatistic = JSON.parse(serverStat);
console.log(serverStatistic);
$('#serverProcessor').html(serverStatistic.processor + "%");
$('#serverMemory').html(serverStatistic.memory + "%");
$('#serverStorage').html(serverStatistic.storage + "%");
};
// Start the connection.
$.connection.hub.start().done(function () {
serverStatistics.server.serverParameter();
});
});
</script>
</body>
</html>
I found a workaround to fix this issue.
I don't know how to describe it.
The following code change done in Hub Class file. "ServerStatisticsHub.cs"
Clients.Client(Context.ConnectionId).broadcastServerStatistics("{\"processor\":" + p + ", \"memory\":" + m + ", \"storage\":" + s + "}");
Changed
Clients.All.
to
Clients.Client(Context.ConnectionId).

Upload, rename and display the image with Ajax asyncfileupload - ASP.NET

I want to upload the image to web server file and get the path and save it to database.
HTML and Javascript
<img id="imgDisplay" alt="" src="" style="display: none" class="img-thumbnail" />
<ajaxToolkit:AsyncFileUpload OnClientUploadComplete="uploadComplete" runat="server"
ID="AsyncFileUpload1" UploaderStyle="Traditional" CompleteBackColor="White" UploadingBackColor="#CCFFFF"
ThrobberID="imgLoader" OnUploadedComplete="FileUploadComplete" OnClientUploadStarted="uploadStarted" />
<asp:Image ID="imgLoader" runat="server" ImageUrl="~/Images/loader2.gif"
Height="21px" Width="23px" />
<script type="text/javascript">
function uploadStarted() {
$get("imgDisplay").style.display = "none";
}
function uploadComplete(sender, args) {
var imgDisplay = $get("imgDisplay");
imgDisplay.src = "images/loader.gif";
imgDisplay.style.cssText = "";
var img = new Image();
img.onload = function () {
imgDisplay.style.cssText = "height:240px;width:240px";
imgDisplay.src = img.src;
};
img.src = "<%=ResolveUrl(UploadFolderPath) %>" + args.get_fileName();
}
</script>
C# code behind, event file upload complete
protected string UploadFolderPath = "~/Images/";
protected void FileUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + filename);
}
With code above, I success to do it... But the problem become when I want to rename the file with GUID, the image not appear after upload.
C# code behind
protected string UploadFolderPath = "~/Images/";
protected void FileUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
string fileext = System.IO.Path.GetExtension(AsyncFileUpload1.FileName);
string file_id = Guid.NewGuid().ToString();
AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + file_id + fileext);
}
I realize in the javascript, it will refer to agrs from file upload control. So that means it cannot refer the new file name.
Javascript
img.src = "<%=ResolveUrl(UploadFolderPath) %>" + args.get_fileName();
So I google to find how to paste a value from code behind to javascript. And I found it. Then modified my behind code something like this
protected string UploadFolderPath = "~/Images/";
protected string image = "";
protected void FileUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
string fileext = System.IO.Path.GetExtension(AsyncFileUpload1.FileName);
string file_id = Guid.NewGuid().ToString();
AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + file_id + fileext);
image = this.ResolveUrl(this.UploadFolderPath) + file_id + filename;
}
And the javascript
<script type="text/javascript">
function uploadStarted() {
$get("imgDisplay").style.display = "none";
}
function uploadComplete(sender, args) {
var imgDisplay = $get("imgDisplay");
imgDisplay.src = "images/loader.gif";
imgDisplay.style.cssText = "";
var img = new Image();
img.onload = function () {
imgDisplay.style.cssText = "height:240px;width:240px";
imgDisplay.src = img.src;
};
img.src = "<%=ResolveUrl(image) %>";
}
</script>
Still not appear because the image variable not have a value inside it. How to solved this?
Sorry for my bad english
Nothing issue with your codes, the only problem i see is that since you edited the path you must revert it back to the original values if you retrieve it unless no image will show.
aspx code for fileupload
<ajax:asyncfileupload id="Asyncfileupload1" onclientuploadcomplete="uploadComplete1"
width="350px" runat="server" uploaderstyle="Traditional"
throbberid="Image6" onuploadedcomplete="Asyncfileupload1_UploadedComplete" />
javascript function
function uploadComplete1()
{
window.location = window.location.href;
}
aspx.cs code
protected void Asyncfileupload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
string name = Asyncfileupload1.FileName;
string[] spi = name.Split('.');
int len = spi.Length;
string type = spi[len - 1];
if (type == "apk" || type == "ipa")
{
if (Asyncfileupload1.PostedFile.ContentLength > 10)
{
string filename = System.IO.Path.GetFileName(Asyncfileupload1.FileName);
string ext = Path.GetExtension(filename);
string newfilename = Path.GetRandomFileName();
newfilename += ext;
Asyncfileupload1.SaveAs(Server.MapPath("~/product_application/") + newfilename);
MobileStoreEntities mse = new MobileStoreEntities();
ProductMast um = new ProductMast();
int loginid = Utility.login_id();
um = mse.ProductMasts.Where(i => i.ProductID == proid).FirstOrDefault();
um.ApplicationFile = "~/product_application/" + newfilename;
int check1 = mse.SaveChanges();
lblDoc.Text = "Old file is available. Want to change? Then Upload";
}
else
{
ScriptManager.RegisterStartupScript(this, GetType(), "TestAlert", "alert('" + "Size problem." + "');", true);
}
//Response.Redirect("ProductFileUpload.aspx?proid="+HttpUtility.UrlEncode(enc));
//Response.Redirect("ProductFileUpload.aspx");
}
else
{
ScriptManager.RegisterStartupScript(this, GetType(), "TestAlert", "alert('" + "Must upload doc, docx or pdf file." + "');", true);
}
}

avoid double when save button is click

I use C# 4.0 and SQL Server 2008 R2 and I've a simple button click that call a function that save the data into database and redirect the page.
The probleme is when the client click more than one on this save button, then i save more than one item also into the database.
I want to avoid the client make a mistake, that meant the client can only do 1 clic = 1 save data.
<dx:ASPxButton ID="ASPxButton_save" runat="server" Image-Url="~/images/Icon/Good-or-Tick-icon.png" Text="Enregistrer" Width="110px" onclick="ASPxButton_save_Click" ValidationGroup="Savebouton">
</dx:ASPxButton>
protected void ASPxButton_save_Click(object sender, EventArgs e)
{
string ErrPos = "";
try
{
ErrPos = "Affct CP DEST";
string FA_Choisi = ASPxTextBox_CP_dest.Text.Substring(0, 2);
string CLIENT_de_FA = ClientId.Substring(0, 2);
List<string> ClotList_FA = new List<string>();
ErrPos = "Affct Trans";
foreach (DataRow myRow in oOrdre_BL.Get_Tranporteur(ClientId).Tables["Le_Transporter"].Rows)
{
ClotList_FA.Add(myRow["LIBELLE"].ToString());
}
Pers_Client_Entrp oPersclientEntrp = GetOPersclientEntrp();
Pers_Ordre oPersOrdr = new
.......
if (ASPxCheckBox_NewDesti.Checked)
{
string ResTemp = oDest_BL.Compare_Dest(ClientId, ASPxTextBox_Desti_ID.Text, ASPxTextBox_RS_NOM_dest.Text, ASPxTextBox_ADRESSE_dest.Text);
if (!String.IsNullOrWhiteSpace(ResTemp))
{
lbl_err.Text = ResTemp;
}
else
{
Pers_Dest TheDest = new Pers_Dest();
TheDest.CodeDest = ASPxTextBox_Desti_ID.Text.Replace('-', ' ').Replace('\'', ' ');
TheDest.CodeClient = ClientId;
TheDest.RaisonSoc = ASPxTextBox_RS_NOM_dest.Text.Replace('-', ' ').Replace('\'', ' ');
TheDest.Adresse = ASPxTextBox_ADRESSE_dest.Text.Replace('-', ' ').Replace('\'', ' ');
TheDest.Cp = ASPxTextBox_CP_dest.Text;
TheDest.Ville = ASPxComboBox_VILLE_dest.Text;
TheDest.Pays = ASPxComboBox_PAYS_dest.Value.ToString();
TheDest.Tel = ASPxTextBox_TEL_dest.Text.Replace('-', ' ').Replace('\'', ' ');
TheDest.Fax = ASPxTextBox_FAX_dest.Text.Replace('-', ' ').Replace('\'', ' ');
TheDest.Email = ASPxTextBox_EMAIL_dest.Text.Replace('-', ' ').Replace('\'', ' ');
TheDest.Insee = ASPxTextBox_INSEE_dest.Text.Replace('-', ' ').Replace('\'', ' ');
TheDest.Siret = ASPxButton_SIRET_dest.Text.Replace('-', ' ').Replace('\'', ' ');
oDest_BL.CrUp_Dest(TheDest, true);
oPersOrdr.Ville = ASPxComboBox_VILLE_dest.Text;
Save_Part(oPersOrdr, oPersclientEntrp, OrdreID);
}
}
else
{
oPersOrdr.Ville = ASPxTextBox_VILLE_dest.Text.Replace('-', ' ').Replace('\'', ' ');
Save_Part(oPersOrdr, oPersclientEntrp, OrdreID);
}
catch (Exception ex)
{
lbl_err.Text = ex.Message;
if (ex.InnerException != null) { lbl_err.Text += "-->" +ex.InnerException.Message; }
Outils_IHM.SendingEmail("Save Odre --> Err Position: " + ErrPos + "-----" + lbl_err.Text, ClientId);
}
private void Save_Part(Pers_Ordre oPersOrdr, Pers_Client_Entrp oPersclientEntrp, string OrdreID)
{
oOrdre_BL.SaveUpdt_Ordre_BL(oPersOrdr, OrdreID);
string QuelleID = TempId;
if (!String.IsNullOrWhiteSpace(OrdreID))
{ QuelleID = OrdreID; }
if (oPersclientEntrp.TypPrint == "Zebra")
{ Response.Redirect("../Print/BonEticket_Web.aspx?ConnPrint=UnDirect&OdreID=" + QuelleID + "&CountOrdre=" + ASPxTextBox_NBR_COLIS.Text + "&TypeAR=" + TypeEnlev, false); }
else
{ Response.Redirect("../Print/BonEticket_Web.aspx?OdreID=" + QuelleID + "&CountOrdre=" + ASPxTextBox_NBR_COLIS.Text + "&TypeAR=" + TypeEnlev, false); }
Context.ApplicationInstance.CompleteRequest();
}
I have an idea, when the user clic this button, than it will call client side function to disable it. But i don't know how and if it work as i want to.
you can use the below mentioned code as ref.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
var submit = 0;
function CheckIsRepeat() {
if (++submit > 1) {
alert('An attempt was made to submit this form more than once; this extra attempt will be ignored.');
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" OnClientClick="return CheckIsRepeat();" />
</div>
</form>
</body>
</html>
Before saving data to database disbale the button , then save the data, then clear the controls & then again enable the button.
<dx:ASPxButton ID="ASPxButton_save" runat="server" Image-Url="~/images/Icon/Good-or-Tick-icon.png" Text="Enregistrer" ClientInstanceName="ASPxButton_save" Width="110px" onclick="ASPxButton_save_Click" ValidationGroup="Savebouton">
<ClientSideEvents Click ="function(s,e) { MyBtnClick(s,e); } " />
</dx:ASPxButton>
function MyBtnClick(s, e) {
if (ASPxClientEdit.AreEditorsValid())
ASPxButton_save.SetVisible(false);
}

asp gridview Print

I have a javascript function as shown below that is working. Note - i did change the line (from the internet examples)
WinPrint.document.write(printContent.innerHTML);
to
WinPrint.document.write(printContent.outerHTML);
i dont think i am supposed to do that but with innerhtml the grid wasnt formatted at all but with the value outerhtml it was fine...
So to summarize
why cant i use innerhtml like all the examples show - must be a bug
in my code somewhere
thanks,
Damo
Javascript
<script type="text/javascript">
function PrintGridData(GridToPrint) {
var printContent = document.getElementById(GridToPrint);
var windowUrl = 'about:blank';
var UserLoggedIn = $("#lblUser").text()
var now = new Date();
var strDateTime = [[AddZero(now.getDate()), AddZero(now.getMonth() + 1), now.getFullYear()].join("/"), [AddZero(now.getHours()), AddZero(now.getMinutes())].join(":"), now.getHours() >= 12 ? "PM" : "AM"].join(" ");
var windowName = 'Report';
var AuditPrintDetail = 'Report ' + UserLoggedIn + " " + strDateTime;
var WinPrint = window.open(windowUrl, windowName, 'left=300,top=300,right=500,bottom=500,width=1000,height=500');
WinPrint.document.write('<' + 'html' + '><head><link href="cssreference" rel="stylesheet" type="text/css" /><link href="assets/css/Main.css" rel="stylesheet" type="text/css" /> <title>' + AuditPrintDetail + '</title> </head><' + 'body style="background:none !important"' + '>');
WinPrint.document.write(printContent.outerHTML);
WinPrint.document.write('<' + '/body' + '><' + '/html' + '>');
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
function AddZero(num) {
return (num >= 0 && num < 10) ? "0" + num : num + "";
}
function printItn() {
//you can put your contentID which is you want to print.
var printContent = document.getElementById('<%= pnlForm.ClientID %>');
var windowUrl = 'about:blank';
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
// you should add all css refrence for your Gridview. something like.
var WinPrint= window.open(windowUrl,windowName,'left=300,top=300,right=500,bottom=500,width=1000,height=500');WinPrint.document.write('<'+'html'+'><head><link href="cssreference" rel="stylesheet" type="text/css" /><link href="gridviewcssrefrence" rel="stylesheet" type="text/css" /></head><'+'body style="background:none !important"'+'>');
WinPrint.document.write(printContent.innerHTML);
WinPrint.document.write('<'+'/body'+'><'+'/html'+'>');
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
reference it from here... click to view discussion.
and also see complete example with sample code javascript to print gridview data from client-side.

Categories