|
Finally!
I have used different sources to get my solutions, some of which I got from codeproject.
Here goes:
default.aspx.cs:
protected void btPrint_Click(object sender, EventArgs e)
{
RenderReport();
Response.Redirect("PrinterFriendly.aspx");
}
private void RenderReport()
{
Warning[] warnings;
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>10in</PageWidth>" +
" <PageHeight>13in</PageHeight>" +
" <MarginTop>0.0in</MarginTop>" +
" <MarginLeft>0.0in</MarginLeft>" +
" <MarginRight>0.0in</MarginRight>" +
" <MarginBottom>0.0in</MarginBottom>" +
"</DeviceInfo>";
m_streams = new List<Stream>();
ReportViewer.LocalReport.Render("Image", deviceInfo, CreateStream, out warnings);
Session["MemStreamList"] = (List<Stream>)m_streams;
}
private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Guid newid = Guid.NewGuid();
Stream stream = new FileStream(name + newid + "." + fileNameExtension, FileMode.Create);
m_streams.Add(stream);
return stream;
}
printerfriendly.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
List<Stream> memList = (List<Stream>)Session["MemStreamList"];
for (int i = 0; i < memList.Count; i++)
{
string imgString = "<img src=\"MultipleImaging.aspx?Index=" + i + "\">";
this.Controls.Add(new LiteralControl(imgString));
}
}
multipleimaging.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if ((Session["MemStreamList"] != null) && Session["MemStreamList"].GetType().Equals(typeof(List<Stream>)))
{
List<Stream> images = (List<Stream>)Session["MemStreamList"];
int index = Int32.Parse(Request.Params.Get(0).ToString());
if (images[index].Length > 0)
{
try
{
System.Drawing.Image image = System.Drawing.Image.FromStream(images[index]);
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
}
catch (Exception ex)
{//Parameter not valid error, ANY HELP HERE WILL BE APPRECIATED, THANKS
//If the same code is executed again it works, please help
System.Drawing.Image image = System.Drawing.Image.FromStream(images[index]);
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
}
}
else
{
//send a default image
}
}
}
Okay, so the above code renders a local report into images, which is saved in a list<stream>. Each stream is a page of the report. Then is redirects it to a printer friendly page which creates an literal image for every item in list<stream> using multipleimaging.aspx. The printerfriendly page contains a print button with btPrint.Attributes.Add("onclick", "javascript:location.reload(true);window.print();"); in page_load.
Hope some one else can find this helpful, please let me know if there is a better/faster way to accomplish client-side printing of a localreport. By the way, does the .net 2008 reportviewer control which does include a printer icon, prints on the server-side or on the client-side?
|
|
|
|
|
what is an exception?
what is diff type of exception?
raja
|
|
|
|
|
Um an exception may be an error in the code if this is the context you are talking about
can you explain a bit more
|
|
|
|
|
|
wt is the diff b/w web application and web application?
how it is executed with iss?
raja
|
|
|
|
|
Member 4708077 wrote: wt is the diff b/w web application and web application?
Am I the only one who sees these two things as the same
|
|
|
|
|
By any chance are you trying to preparing for an interview and throwing silly questions onto a public discussion framework.
I really pity your poor potential employer who is going to be associated with you.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
* Please note i have also posted this in SQL forum as i dont know which is most appropriate. If a mod feel it is wrongly placed here i appologise, feel free to delete.
Problem:
Hi,
I need help with an sql query please.
I wish to insert a new record into a table, and instantly retreive the new records id. Is it possible to do this in one sql statement rather than an INSERT followed by the SELECT statement?
My INSERT looks like this:
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["artisanConnectionString"].ConnectionString;
SqlConnection uniqueCon = new SqlConnection(conn);
//set SQL statement
SqlCommand cmd = new SqlCommand("INSERT INTO [tbl_Additional] (add_Item, add_Price) VALUES ('" + TextBox10.Text + "', '" + TextBox11.Text + "') ", uniqueCon);
cmd.Connection.Open();
try
{//insert/ add new record
//commit to database
cmd.ExecuteNonQuery();
//clear form add/edit
TextBox10.Text = null;
TextBox11.Text = null;
//confirm to user
ShowMessageBox("New unique Item Added!");
//update dataset
GridView2.DataBind();
}
catch
{
ShowMessageBox("Unable to add record!!! Please try again later.");
}
cmd.Connection.Close();
Any help would be greatly appreciated.
Thanks & Happy Easter!
|
|
|
|
|
Before you attempt resolving this problem on hand, seriously consider a re-design of your database query approach. Your application is vulnerable for SQL Injection attacks.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
how to get columns of table in order of their ordinal position instead of
alphabetical order of column name?
cn.GetSchema("Columns", restrictions)
output: column_name ordinal_position
...........ambit...............3
...........noise...............1
...........z...................2
required output: column_name ordinal_position
....................noise...............1
....................z...................2
....................ambit...............3
IS IT POSSIBLE?
|
|
|
|
|
hmm
try sort by ordinal_position in the query
unless I have mistaken your post
|
|
|
|
|
Hi,
I am using Ajaxcalendar control for dates as inputs value.
my requirement, i have validated the dates, that is i am using Rangevalidator control and compare validator for validation.
its working fine, if the date format is mm/dd/yyyy.
In my Application i have mulitple language selection,when i selected Germam,then the date format will be changed to dd.mm.yyyy, then i am unable to validate the textboxes.
please help me.
thanks & regards,
Mohan
|
|
|
|
|
its very urgent*****************************************
I'm sure it is to you but its annoying and will just get your ignored
only two letters away from being an asset
|
|
|
|
|
Well If i understand your post correctly you just need to find a validator which will compare all types of date formats correctly
I'm sure if you search the Internet you will find one which validates all the correct formats
hope this makes sense ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
|
no trying searching yourself and then provide what you have found so far then we can help you
|
|
|
|
|
I think it will solve your problem?
<asp:regularexpressionvalidator id="RegularExpressionValidator2" runat="server" controltovalidate="txttodate" errormessage="Enter Correct Date">
ValidationExpression="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d">
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
|
hi all
how to open multiple windows in asp.net.. pleas help
i need to generate the same quotation for several partners like a,b,c,d...
i am using this code in the save button ie.. how many records it inserts it should display the Quotaion or pop up the window...
ClientScript.RegisterStartupScript(Me.GetType(), "Message", "<script>window.open('frmquotation.aspx?quot=" & ViewState("Order") & "&pid=" & partner.Text & "&Type=" & ddlLeadtype.SelectedItem.Text & "&custid=" & ViewState("CustIdCOrp") & " &sourceLead=" & ddlLeadSource.SelectedItem.Text & "&optprint=" & rdPrint.SelectedItem.Text & "','a' + new Date().getTime(),'resizable=1,scrollbars=yes,width=800,height=768')</script>", True)
if there is any other way to display plz let me know..its very urrgent ![Frown | :(](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_frown.gif)
|
|
|
|
|
Did you mean multiple windows or multiple steps in the opened child window?
The first statement and subsequent clarifications of your post contradict to a good chunk.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
window.open() is the only way to open multiple windows.
no any other way to open them.
you can use any extra tools for popup windows to display your recodrs which may be you can get from ajax toolkit.
|
|
|
|
|
I have a problem using ajaxToolkit:MaskedEditExtender..
if enter the value in time textbox but value should be greater than 12 hour format..is there anyway to solve the problem ..please help me.
<asp:textbox id="addrow15" width="80%" runat="server">
<ajaxtoolkit:maskededitextender id="MaskedEditExtender5" targetcontrolid="addrow15">
Mask="99:99" AcceptAMPM="true" MessageValidatorTip="true" MaskType="Time" ClearMaskOnLostFocus="true"
OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError" InputDirection="RightToLeft"
runat="server" />
|
|
|
|
|
currently i m using ASP.NET with C# (.net 2005, 2.0 framework)
i have placed a calendar in my webform (calendar from "toolbox --> calendar"). when i press the ESC key, the calendar should get INVISIBLE... how to do this?
help me. - KARAN
|
|
|
|
|
You could use this and then find the correct key number for esc, i think this one is for when the enter button is pressed
if (window.event.keyCode == 13)
{
calendar.visible - false
}
hope this helps ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
i cant get the "window.event.keyCode" and where should i write this code?... where it is?
|
|
|
|