|
I received the following error in
cmdDatabase.Parameters.AddWithValue("@Signature", saveInk);
which is
object reference is not set to the instance of object
|
|
|
|
|
So debug your code and find out which object is null .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Where did you assign a value to saveInk? How does your current code look?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi, is it possible to convert a char array to a nullable char array?
string myString;
char?[] charArray = (char?[])(myString.ToCharArray());
modified 17-Oct-16 9:26am.
|
|
|
|
|
Not directly. Each element has to be cast to a char?. Probably use Linq
char?[] charArray = myString.Cast<char?>().ToArray()
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
No, Char is just a single letter or number. Char[] is a list of Chars. You can loop the list and concatenate a string or if the list have a fixed size declare a Char for each element and fill when you loop the list.
|
|
|
|
|
I have a form with three controls: updateprogress, AsyncFileUpload and button; my problem is de next one:
I have two stages:
--- Stage 1 using AsyncFileUpload
1.- When press the button (with trigger PostBackTrigger), UpdateProgress not appear but AsyncFileUpload works fine.
2.- When press then button (with trigger AsyncPostBackTrigger), Udateprogress appear but not disappear any more.
--- Stage 2 without AsyncFileUpload (removing control AsyncFileUpload)
1.- When press the button (with trigger PostBackTrigger), UpdateProgress not appear.
2.- When press then button (with trigger AsyncPostBackTrigger), Udateprogress appear and disappear.
My problem is that i need using AsyncFileUpload with updateprogress but no works properly.
Any body know what´s my problem?
if you wish, i can send you my project by email.
Greetings and sorry by my English.
|
|
|
|
|
It sounds to me like you may not be marshalling the calls to your controls back on to the UI thread. Whenever you make a call to a control, or set a property, you need to use the "InvokeRequired ...Invoke " pattern. Take a look here[^] - it explains it all. The pattern I speak of is about 1/3 of the way down the page.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
That's not really relevant in an ASP.NET application.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am trying to print a questionnaire which has 6 check-boxes. I am following a tutorial but this tutorial does not have check-boxes. Below prints except for the check-box. The text in the checkbox prints but prints if checked or not. I need some kind of statement to print if checked but cant find any examples of doing so.
private void metroButton3_Click(object sender, EventArgs e)
{
DSprintPreviewDialog.Document = DSprintDocument;
DSprintPreviewDialog.ShowDialog();
}
private void DSprintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bmp = Properties.Resources.dslogo;
Image newImage = bmp;
e.Graphics.DrawString("Customer Name: " + metroTextBox2.Text, new Font("Arial", 16, FontStyle.Regular), Brushes.Black, new Point(25, 180));
e.Graphics.DrawString("Date: " + DateTime.Now, new Font("Arial", 12), Brushes.Black, new Point(25, 100));
e.Graphics.DrawString("Computer Make: " + metroMakeBox28.Text, new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(25, 250));
e.Graphics.DrawString("Customer Items: " + metroCheckBox1.Text, new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(25, 320));
I've changed the following but it prints with a True or False
e.Graphics.DrawString("Customer Items: " + metroCheckBox1.Checked + metroCheckBox1.Text, new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(25, 320));
|
|
|
|
|
If you are asking what I think you are asking, this[^] is how you write an if statement in C#.
|
|
|
|
|
The framework has a nice tool to help here[^]. Check out the DrawCheckBox Method[^] overloads.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
checkbox control checked property will only return either true or false. Also the text property only returned the text associated with the control.
One way around that I come up is that:
You will have to write an if statement before the e.Graphics.Drawstring.
if(metroCheckBox.checked)
{
>e.Graphics.DrawString("Customer Items: " + metroCheckBox1.Text, new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(25, 320));
}
else
{
}
Umair
(Software Engineer)
(Interested in C#, .Net, Interfacing, Device Drivers, GIS, WCF, Asp.net, Ajax, Architecture and Design Patterns)
|
|
|
|
|
How an organization should leverage polymorphism in the definition of standards to reduce the lines of code.
|
|
|
|
|
1) By dumping the buzzwords in favour of English that means something without actually inducing vomiting.
2) By doing their own homework rather than trying to get others to do it for them ...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You forgot
0) by putting the water in the coffee machine. The Lounge[^]
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I hadn't noticed it was ORT until I saw that one.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Line count is absolutely meaningless.
Source code isn't for computers, silly. Now go tell your instructor that truth and see what happens
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Dear team,
Can you please help me out to integrate the Facebook Marketing API in my windows application using c#.
Please provide me the sample app code if possible, or please provide the URL to hit and the parameter need to pass on that URL.
|
|
|
|
|
|
Please help if any one has worked on itextsharp.
|
|
|
|
|
i have used
using iTextSharp.text;
using iTextSharp.text.pdf;
-------------//usage///
var baseUrl = SecurityContext.BaseUrl;
string urlString = string.Format("{1}Downloads/SalesOrderInvoice.aspx?id={0}", OrderId, baseUrl);
Uri url = new Uri(urlString);
IDownloader htmlToPDFDownloader = new HtmlToPDFDownloader(url);
string fileName = string.Format("Invoice for Order Referecne. {0}", OrderCode);
htmlToPDFDownloader.Download(fileName);
---------------------------------
Create a interface IDownloader.cs
-------------------------
public interface IDownloader
{
object GetDownloadable();
void Download(string fileName);
}
-------------------------
HTMLToPDFDownloader.cs
---------------------------
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.draw;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Web;
namespace sampleproj.Client
{
public class HtmlToPDFDownloader : IDownloader
{
private string htmlString;
public HtmlToPDFDownloader(string htmlString)
{
this.htmlString = htmlString;
}
private string ImageToBase64(string url)
{
WebClient client = new WebClient();
byte[] bytes ;
if(url.StartsWith("http"))
{
bytes = client.DownloadData(url);
}
else
{
string physicalPath = HttpContext.Current.Server.MapPath(string.Format("~{0}", url));
bytes = File.ReadAllBytes(physicalPath);
}
string base64String = Convert.ToBase64String(bytes);
return "data:image/png;base64," + base64String;
}
public HtmlToPDFDownloader(Uri url)
{
WebClient client = new WebClient();
client.Headers.Add("_uidqqweb4324", ConfigurationManager.UserId);
this.htmlString = client.DownloadString(url);
foreach (Match m in Regex.Matches(htmlString, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
string src = m.Groups[1].Value;
string physicalPath = ImageToBase64(src);
htmlString = htmlString.Replace(src, physicalPath);
}
}
private byte[] GetStream()
{
MemoryStream stream = new MemoryStream();
var htmlContent = this.htmlString;
var converter = new NReco.PdfGenerator.HtmlToPdfConverter();
converter.Margins = new NReco.PdfGenerator.PageMargins
{
Bottom = 5,
Left = 2.5f,
Right = 2.5f,
Top = 5
};
var pdfBytes = converter.GeneratePdf(htmlContent);
return pdfBytes;
}
public object GetDownloadable()
{
return GetStream();
}
public void Download(string fileName)
{
var pdfBytes = GetStream();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf; file";
HttpContext.Current.Response.AddHeader("content-length", pdfBytes.Length.ToString());
fileName = fileName + "_" + DateTime.Now.ToString("ddMMMyyy") + ".pdf";
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;" + "filename=" + fileName);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.BinaryWrite(pdfBytes);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
HttpContext.Current.Response.End();
}
}
}
-----------------------------
SecurityContext.cs
-----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EnergyEngineers.Client
{
public class SecurityContext
{
public int CurrentUserId
{
get
{
return 1;
}
}
public static string BaseUrl
{
get
{
return HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpRuntime.AppDomainAppVirtualPath;
}
}
}
}
|
|
|
|
|
I've been playing with jsPDF[^] lately. Aside from highly limited CSS support, it's fairly excellent.
The AutoTable plugin also works exceptionally well.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
hi check this link
[^]
|
|
|
|
|
Is there a better way to run the Stop Watch:
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace StopWatch
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Stopwatch StopWatch = new Stopwatch();
private void lblClock_Click(object sender, EventArgs e)
{
}
private void btnStart_Click(object sender, EventArgs e)
{
if (timer1.Enabled)
{
MessageBox.Show("Sorry you have already started the Timer");
}
else
timer1.Start();
this.StopWatch.Start();
}
private void btnStop_Click(object sender, EventArgs e)
{
if (timer1.Enabled)
{
timer1.Stop();
StopWatch.Stop();
}
else
MessageBox.Show("Timer Already Stopped");
}
private void btnPause_Click(object sender, EventArgs e)
{
StopWatch.Reset();
lblClock.Text = "00 HR :00 MIN :00 SEC ";
}
private void timer1_Tick(object sender, EventArgs e)
{
TimeSpan elapsed = this.StopWatch.Elapsed;
lblClock.Text = string.Format("{0:00} HR :{1:00} MIN: {2:00} SEC", Math.Floor(elapsed.TotalHours), elapsed.Minutes, elapsed.Seconds);
}
}
}
Class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace StopWatch.BL
{
public class Time
{
Stopwatch stopwatch = new Stopwatch();
public TimeSpan Elapsed
{
get { return stopwatch.Elapsed; }
}
public bool IsRunning
{
get { return stopwatch.IsRunning; }
}
public void Start()
{
DateTime start = DateTime.Now;
TimeSpan duration = DateTime.Now - start;
}
public void Stop()
{
stopwatch.Stop();
}
public void Reset()
{
stopwatch.Reset();
}
}
}
|
|
|
|
|