|
As I understand it you want to send the feedback someone enters on your form as an email to your gmail account.
Have a look at the SmtpClient[^] Class and the MailMessage [^] Class from the System.Net.Mail Namespace. Other than the examples on MSDN you should also find plenty of examples by searching for it on google.
|
|
|
|
|
k thanks nic.. i will try it.
|
|
|
|
|
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 18: protected void Page_Load(object sender, EventArgs e)
Line 19: {
Line 20: if (Request.QueryString["studentName"].ToString().Trim() == "") lblStudentName.Text = "No Record Found"; else lblStudentName.Text = Request.QueryString["Name"].ToString().Trim();
Line 21: if (Request.QueryString["studentCode"].ToString().Trim() == "") lblStudentCode.Text = "No Record Found"; else lblStudentCode.Text = Request.QueryString["Code"].ToString().Trim();
Line 22: }
Source File: D:\sanjib\niose\noise\noise\noise\recordSaved.aspx.cs Line: 20
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
noise.recordSaved.Page_Load(Object sender, EventArgs e) in D:\sanjib\niose\noise\noise\noise\recordSaved.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
|
|
|
|
|
have you checked that
Request.QueryString["studentName"]
or
Request.QueryString["Name"]
is not actually null?
A string is nullable. That means if while accessing the QueryString it can't find the provided key (e.g. "studentName" it might very likely return null.
If you call the method ".ToString()" or ".Trim()" on this null string this will raise an exception.
(Note: you're using 2 different keys for accessing the name, I don't know however if that is intended.)
|
|
|
|
|
Don't double post the same question.
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["Name"].ToString().Trim() == "") lblStudentName.Text = "No Record Found"; else lblStudentName.Text = Request.QueryString["Name"].ToString().Trim();
if (Request.QueryString["Code"].ToString().Trim() == "") lblStudentCode.Text = "No Record Found"; else lblStudentCode.Text = Request.QueryString["Code"].ToString().Trim();
}
|
|
|
|
|
Where is the problem?
I would guess at the code that you have given, that either "Name" or "Code" doesn't exist.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 18: protected void Page_Load(object sender, EventArgs e)
Line 19: {
Line 20: if (Request.QueryString["studentName"].ToString().Trim() == "") lblStudentName.Text = "No Record Found"; else lblStudentName.Text = Request.QueryString["Name"].ToString().Trim();
Line 21: if (Request.QueryString["studentCode"].ToString().Trim() == "") lblStudentCode.Text = "No Record Found"; else lblStudentCode.Text = Request.QueryString["Code"].ToString().Trim();
Line 22: }
Source File: D:\sanjib\niose\noise\noise\noise\recordSaved.aspx.cs Line: 20
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
noise.recordSaved.Page_Load(Object sender, EventArgs e) in D:\sanjib\niose\noise\noise\noise\recordSaved.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
|
|
|
|
|
Can you please let me know the url. I think problem is in your querystring parameters.
|
|
|
|
|
Delete your other post there is no need for it. Click the Delete button at the bottom.
The reason you are getting a null reference is because you are trying to ToString where one of your references is not present. This is the thing that's causing the problem. What you need to do is actually test the result from the QueryString before you attempt to do anything with it. You could use something like this:
lblStudentName.Text = GetResultFromQueryString("studentName");
private string GetResultFromQueryString(string queryString)
{
string returnValue = "No record found";
object result = Request.QueryString(queryString);
if (result != null && !string.IsNullOrWhiteSpace(result.ToString())
{
returnValue = result.ToString();
}
return returnValue;
}
|
|
|
|
|
Did you not notice that the second folder is spelt differently?
D:\sanjib\niose\noise\noise\noise\recordSaved.aspx.cs Line: 20
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
I missed that in all the noise.
|
|
|
|
|
The multiple posts are quite noisy too.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
i got a table which contains columns starttime and endtime ,and i want to show data in a gridview ,but how can i show the datetime of now compared with the two ,then shows "expired, progressing,not started"
do in the sql? or create a function in .cs?
|
|
|
|
|
My sql solution - not tested. It can still be done in .cs
I will create a function
Create FUNCTION [dbo].[fn_GetStatus]
(
@StartDate Datetime,
@EndDate Datetime
)
RETURNS NVARCHAR(50)
BEGIN
DECLARE @Status NVARCHAR(50)
IF @StartDate < getdate()
BEGIN
SET @Status = 'not started'
END
IF (@StartDate >= getdate() AND @EndDate <= getdate())
BEGIN
SET @Status = 'progressing'
END
IF (@EndDate > getdate())
BEGIN
SET @Status = 'expired'
END
RETURN @Status
END
Then call
SELECT starttime, endtime, dbo.fn_GetStatus(starttime, endtime) AS Statuses from TableName
I remain joe!
|
|
|
|
|
All,
I'm trying to replicate a design of a GUI which has numerous circles scattered across the form to represent the equivalent of an LED status light.
I'm a total noob at C# 2005, but my million dollar question is how can I do this?
|
|
|
|
|
Stuck At Zero wrote: ... million dollar question ...
For a million dollars, there are lots of us here who will do it for you! 
|
|
|
|
|
Start here[^].
Use the best guess
|
|
|
|
|
I'm actually trying to draw permanent circles onto the Form view of the app I'm trying to create to emulate LED status lights.
Is there nothing on the toolbox that I can use to draw circles directly onto the form view?
|
|
|
|
|
Not that I'm aware of, but you could possibly adapt one of the existing tools, or create a custom one of your own. Google for "custom tools" to find some samples and tutorials.
Use the best guess
|
|
|
|
|
I guess my only options may be to see if I can investigate if I can place 40+ buttons onto the form that I can disable but have visible and see if I can make them circular buttons with the ability for me to change the color of the button.
My other way I suppose would be to draw a circle on something like MS Paint and somehow save it with a transparent background. 50+ pictures on a form. The idea would be to either forcibly change the color of the circle on the picture or to use a different picture of the circle of a different color when an event happens. that I can simply change the color of the circle in the picture as needed (or have varying pictures of the same circle).
I actually thought this was going to be rather easy, but it seems making simple shapes on the GUI is not as easy as I had thought for C#.
Am I better off doing this on Visual C++ or Visual Basic?
|
|
|
|
|
Sounds like you're using Windows Forms. If you were to use WPF (Windows Presentation Foundation), then drawing circles and flipping their color would be trivial.
Do you have to use C# 2005? Why don't you move to 2010 or 2012 (even 2008)? You're simply making things harder for yourself with "older" technology.
|
|
|
|
|
I am using C# 2005 because the workgroup I'm in at work uses C# 2005. I would love to use "newer" technology, but the decision is above my paygrade.
I'm not sure what forms I'm using, other than it's what pops up when I try to make a GUI. Is WPF something that came out in a later version?
|
|
|
|
|
Whether you use "Windows Forms" or "WPF" is usually determined when you create a new Visual Studio project: i.e. choosing Console; Windows Forms; WPF; etc. when you create a new project.
WPF has been around for a while, but since I have only been using it from 2008 on, I don't know how 2005 supports it.
Anyway, if you're limited to 2005, create a new project in VS, and if you have the option to create a WPF project, then you're good to go (unless "the powers that be" insist you use only Windows Forms).
|
|
|
|
|
I'm a total newbie when it comes to C#, so I've been trying to wing it with online tutorials on making GUI apps.
Powers that be don't really care HOW I do it. They just want to see a notional version of what they had envisioned.
|
|
|
|