Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Thursday, March 29, 2012

Please advise me

Hi Everybody,

I am very much novice to .NET.At present i am working in C,Unix Product development.I got no experience in .net infact i am a fresher who is holding months of experience.I am interested in .net development also am anticipating some development works in .net in my firm.

i dont have any knowledge in this domain.and dont know how to start.

Having said by some of my collegues that asp.net and C# are having better oppurtunities today i want to choose the same path to start up my carrer in .Net .

Can any one please kindly advise me how to start up with .net and what meterial to follow?

Awaiting for your response

Thank you

with regards,

Srikanth

Hi,

and welcome to the ASP.NET forums.

You can freely download the VWD Express tool on this site, take the Tutorials and follow the Guided tour. That'll give you some insight. I read that you already developed with C so I would like to advice you to learn C# as your main development language in .NET.

If you're looking for a decent book you can search through the Book reviews forum and if you should have questions you can visit the forums and ask them.

Grz, Kris.

PS: have fun!


Welcome!

Download VWD Express edition from www.asp.net site. In this edition webserver is in built, no need of IIS for development purpose.

To know about asp.net refer following link:

http://samples.gotdotnet.com/quickstart/aspplus/doc/whatisaspx.aspx

If you don't about web programming, I suggest you to read basics ofHTML (tags) , JavaScript (useful for client side programming), .NETframework architecture.

Best of luck.

For any further difficulties in ASP.NET please visit this forum.

:-)

Regards

Kuldeep Deokule.

deokule2003 wrote:

If you don't about web programming, I suggest you to read basics of HTML (tags) , JavaScript (useful for client side programming), .NET framework architecture.

A nice site to learn more about these ishttp://www.w3schools.com/ or you can also take a look at the official documents:http://www.w3.org/TR/.

Grz, Kris.

Please correct this error

please correct this error while debugging

it show the message box like this when we start the debugging in dot net 2003
But IIS is working properly.if i go for debugging it give this error.

Actually i have loaded 2003 and 2005 in single operating system , but don't say remove 2005 it working properly.

"Error while trying to run project : Unable to start debugging on the web ser server"

Click Help for More Information

OK Help

Plz help me.......... i am unable work without debugging some times.
if any one know reply me

Thx in advance

Hi

you have <compilation debug="false" /> in we.config

change it to <compilation debug="true" />


Hi,

Check out my post on the same topic:

http://geekswithblogs.net/vivek/archive/2006/09/12/90930.aspx

HTH,

Vivek

Monday, March 26, 2012

Please guys, help me out !

Guys,
I have a very very basic user control which is
txtEmail
txtPassword
btnLogIn
I'm working on flowlayout mode...i created a complete web page...it collects some data from the user...and finally added aSubmit button.. the page is working perfect...when u click Sumit...as we know..the page will be sumitted...then...i added my very very basic user control at the left of the page ( tables and cells and that stuff) ...run the page...click the Sumbit button (that was working one minute ago) and nothig happens...i tried EVERY THING...and nothing happened...i dont know why the button click event is not being fired !!!
everything is ok...the event handler exists...it is wired wiht on click event in intitalize component function...everything everything is Ok
I'm using VS.NET 2003 (ASP.NET 1.1)
Please guys help me asap
Thanks in advancecan you post some code please...
HTML and code behind
Thanks
Leketje
Please check whether you have handles the IsPostBack event.
The User Control
================
HTML
(%@. Control Language="c#" AutoEventWireup="false" Codebehind="Search.ascx.cs" Inherits="Controls.SearchbyName" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %)
(HTML)
(HEAD)
(LINK media="all" href="http://links.10026.com/?link=Controls\ControlsStyles.css" type="text/css" rel="stylesheet")
(/HEAD)
(body)
(form name="frmMain")
(table cellSpacing="0" cellPadding="0")
(tr)
(td)
(TABLE cellSpacing="0" cellPadding="0")
(TR)
(TD style="PADDING-LEFT: 4px" vAlign="top")
(asp:TextBox id="txtEmailAddress" Runat="server" Width="120px" CssClass="SRTextBox")(/asp:TextBox) (/TD)
(/TR)
(tr)
(TD style="PADDING-LEFT: 4px" vAlign="top" align="left")
(asp:TextBox id="txtPassword" Runat="server" Width="60px" CssClass="SRTextBox" TextMode="Password")(/asp:TextBox)
(/TD)
(/TR)
(TR)
(TD class="LeftPanelButton" style="PADDING-LEFT: 38px; PADDING-BOTTOM: 5px" align="right" colSpan="2")
(asp:Button id="btnLogin" Runat="server" Text="Login")(/asp:Button)
(/TD)
(/TR)
(/TABLE)
(/td)
(/tr)
(/table)
(/form)
(/body)
(/HTML)

Code Behind

namespaceMyNameSpace.Controls

{

using System;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

///<summary>

/// Summary description for SearchbyName.

///</summary>

publicclass SearchbyName : System.Web.UI.UserControl

{

protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;

protected System.Web.UI.WebControls.TextBox txtPassword;

protected System.Web.UI.WebControls.Button btnLogin;

protected System.Web.UI.WebControls.TextBox txtEmailAddress;

protected System.Web.UI.WebControls.TextBox txtName;

privatevoid Page_Load(object sender, System.EventArgs e)

{

if(!IsPostBack)

{

}

}

#region Web Form Designer generated code

overrideprotectedvoid OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

///<summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///</summary>

privatevoid InitializeComponent()

{

this.btnLogin.Click +=new System.EventHandler(this.btnLogin_Click);

this.Load +=new System.EventHandler(this.Page_Load);

}

#endregion

privatevoid btnLogin_Click(object sender, System.EventArgs e)

{

Response.Write("Help me please");

}

}

}

The web page
===========
HTML
(%@. Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.WebForm1" %)
(%@. Register TagPrefix="uc1" TagName="Search" src="http://pics.10026.com/?src=Search.ascx" %)
(!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" )
(HTML)
(HEAD)
(title)WebForm1(/title)
(meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1")
(meta name="CODE_LANGUAGE" Content="C#")
(meta name="vs_defaultClientScript" content="JavaScript")
(meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5")
(/HEAD)
(body)
(form id="Form1" method="post" runat="server")
(table)
(tr)
(td)
(uc1:Search id="Search1" runat="server")(/uc1:Search)
(/td)
(/tr)
(tr)
(td)
(asp:Button id="Button1" runat="server" Text="Button")(/asp:Button)
(/td)
(/tr)
(/table)
(/form)
(/body)
(/HTML)

Code Behind

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace WebApplication2

{

///<summary>

/// Summary description for WebForm1.

///</summary>

publicclass WebForm1 : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Button Button1;

privatevoid Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

}

#region Web Form Designer generated code

overrideprotectedvoid OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

///<summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///</summary>

privatevoid InitializeComponent()

{

this.Button1.Click +=new System.EventHandler(this.Button1_Click);

this.Load +=new System.EventHandler(this.Page_Load);

}

#endregion

privatevoid Button1_Click(object sender, System.EventArgs e)

{

}

}

}

================
I'm sorry for that HTML Crap...it seems i cant use the editor here !!!
Thanks in advance


Deepasmi, thanks...but the point is ...there is no post back !!!
i'm not waiting the button to do something and it didnt...no...the event is not fired at all !!
thanks

The reason why your button doesn't work is because you are including the <html> tags in your user control again...
The main idea of a user control is to create a HTML template with code behind to be included in the main page which already contains the <HTML><HEAD><BODY> and <FORM> tags.
Remove those tags in your user control and your button should work again.
Good Luck
Leketje


Thanks...thanks ...thanks :D:D:D...thaks Leketje...i passed more than 10 hours trying everything...again..thanks :)

Please help

I am completely perplexed as to why the code below is not functioning. Let me clarify that, the first portion of the code below is working just fine, meaning the "For Next" loop, but the code that is supposed to execute the Stored Procedure isn't even firing. I know that the code isn't making the request to the database because I asked our SQL Admin to turn Trace on and watch for the request. I know that my connection string to the Database is fine because I use this code elsewhere without any problems.

Any assistance would be very much appreciated. Thanks.


Public Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
'Build list of message recipients
Dim dlItem As DataListItem
Dim Recipients As String
For Each dlItem In dtlAssocList.Items
Dim chbSelAssoc As CheckBox = CType(dlItem.FindControl("chbSelAssoc"), CheckBox)
If chbSelAssoc.Checked = True Then
Dim lblAssocCode As Label = CType(dlItem.FindControl("lblAssocCode"), Label)
Recipients += lblAssocCode.Text + ","
End If
Next dlItem

'Check to see if the SelectAll checkbox is checked.
Dim SelectAll As String
If chbSelectAll.Checked = True Then
SelectAll = "1"
Else
SelectAll = "0"
End If

Dim cnnConnection As System.Data.SqlClient.SqlConnection
Dim connString2 As String = ConfigurationSettings.AppSettings("connString2")
Dim cmdCommand As System.Data.SqlClient.SqlDataAdapter

cnnConnection = New System.Data.SqlClient.SqlConnection(connString2)
cmdCommand = New System.Data.SqlClient.SqlDataAdapter("wpsp_MM_I_Message", cnnConnection)

cmdCommand.SelectCommand.CommandType = CommandType.StoredProcedure

cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.msg_title", SqlDbType.VarChar, 50))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.msg_title").Value = txbMsgTitle.Text
cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.msg_text", SqlDbType.VarChar, 500))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.msg_text").Value = txbMessageText.Text
cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.sendAll", SqlDbType.Bit, 1))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.sendAll").Value = SelectAll
cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.AssocList", SqlDbType.VarChar, 4000))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.AssocList").Value = Recipients

Response.Redirect("ManagersMessage.aspx")
End Sub

Hmmm, ... where do you execute your command? It seems that you forgot the execution of the command.
You are not aactually doing anything here. You are setting parameters, and then doing nothing. You never open the connection or fill a dataset or anything.

You should debug the application (if using VS.NET) or otherwise, you can use tracing or even Response.Write() to see where you are going.

What are you indending to do?
The 'wpsp_MM_I_Message' Stored Procedure takes the variables that I pass to it and then executes another Stored Procedure (behind the scenes).

What code do I need to include to get the 'wpsp_MM_I_Message' Stored Procedure to execute?
Presuming this returns no records:


Dim cnnConnection As System.Data.SqlClient.SqlConnection
Dim connString2 As String = ConfigurationSettings.AppSettings("connString2")
Dim cmdCommand As System.Data.SqlClient.SqlCommand

cnnConnection = New System.Data.SqlClient.SqlConnection(connString2)
cmdCommand = New System.Data.SqlClient.SqlDataAdapter("wpsp_MM_I_Message", cnnConnection)

cmdCommand.CommandType = CommandType.StoredProcedure

cmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.msg_title", SqlDbType.VarChar, 50))

cmdCommand.Parameters("@.msg_title").Value = txbMsgTitle.Text

cmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.msg_text", SqlDbType.VarChar, 500))
cmdCommand.Parameters("@.msg_text").Value = txbMessageText.Text

cmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.sendAll", SqlDbType.Bit, 1))
cmdCommand.Parameters("@.sendAll").Value = SelectAll
cmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.AssocList", SqlDbType.VarChar, 4000))
cmdCommand.Parameters("@.AssocList").Value = Recipients

cmdCommand.ExecuteNonQuery()

Note cmdCommand is changed into a SqlCommand object rather than a SqldataAdapter

if it returns records, you could either create a SQLDataReader or a Dataset
That's what I needed. Thank you very much.

Please Help - Allow Paging on Grid Properties Builder

Hi,

I'm working on a grid when the database returns ... say 100 rows. I would
like to use the Allow Page in the grid Properties, but don't really know how
to code it right. I copied some code from the help, but it doesn't really
work yet. The compiler complains on the following...

private void InitializeComponent()
{
this.gridLegalEntityEmployee.SelectedIndexChanged += new
System.EventHandler(this.gridLegalEntityEmployee_S electedIndexChanged);
this.gridLegalEntityEmployee.PageIndexChanged += new
System.EventHandler(this.gridLegalEntityEmployee_P ageIndexChanged );

this.Load += new System.EventHandler(this.Page_Load);

}

private void gridLegalEntityEmployee_PageIndexChanged( object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
gridLegalEntityEmployee.CurrentPageIndex = e.NewPageIndex;
gridLegalEntityEmployee.DataBind();
}

=== Error ======
this.gridLegalEntityEmployee_PageIndexChanged =>
'cpNET.WebForm1.gridLegalEntityEmployee_PageIndexC hanged(object,
System.Web.UI.WebControls.DataGridPageChangedEvent Args)' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'

Here is some other sniplet code

================================================== ==============
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
gridLegalEntityEmployee.AllowPaging = true;
gridLegalEntityEmployee.PagerStyle.Mode = PagerMode.NumericPages;
gridLegalEntityEmployee.PagerStyle.PageButtonCount = 15;
gridLegalEntityEmployee.PageSize = 15;

LoadLegalEntityEmployeeList();

if (!Page.IsPostBack)
{
gridLegalEntityEmployee.DataBind();
}
}

private void LoadLegalEntityEmployeeList()
{
LegalEntityEmployee leEmployee = new LegalEntityEmployee();

// Retrieve data from database
gridLegalEntityEmployee.DataSource = leEmployee.SelectAll();

// Bind it to Databind
gridLegalEntityEmployee.DataBind();
}
================================================== ==============

I know there is a stupid mistake I made here, but I just cant't see it. Any
suggestion or recommeded is greatly appreciated. I really appriciate you
guys help.

Thanks a lot.

Eddyyou page index changed event is mapped to the wrong handler
it should be
System.Web.UI.WebControls.DataGridPageChangedEvent Handler instead of
system.eventhandler

"Eddy Soeparmin" <esoeparmin@.clientprofiles.com> wrote in message
news:OyTwWzjSDHA.940@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I'm working on a grid when the database returns ... say 100 rows. I would
> like to use the Allow Page in the grid Properties, but don't really know
how
> to code it right. I copied some code from the help, but it doesn't really
> work yet. The compiler complains on the following...
> private void InitializeComponent()
> {
> this.gridLegalEntityEmployee.SelectedIndexChanged += new
> System.EventHandler(this.gridLegalEntityEmployee_S electedIndexChanged);
> this.gridLegalEntityEmployee.PageIndexChanged += new
> System.EventHandler(this.gridLegalEntityEmployee_P ageIndexChanged );
> this.Load += new System.EventHandler(this.Page_Load);
> }
> private void gridLegalEntityEmployee_PageIndexChanged( object source,
> System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
> {
> gridLegalEntityEmployee.CurrentPageIndex = e.NewPageIndex;
> gridLegalEntityEmployee.DataBind();
> }
> === Error ======
> this.gridLegalEntityEmployee_PageIndexChanged =>
> 'cpNET.WebForm1.gridLegalEntityEmployee_PageIndexC hanged(object,
> System.Web.UI.WebControls.DataGridPageChangedEvent Args)' does not match
> delegate 'void System.EventHandler(object, System.EventArgs)'
> Here is some other sniplet code
> ================================================== ==============
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> gridLegalEntityEmployee.AllowPaging = true;
> gridLegalEntityEmployee.PagerStyle.Mode = PagerMode.NumericPages;
> gridLegalEntityEmployee.PagerStyle.PageButtonCount = 15;
> gridLegalEntityEmployee.PageSize = 15;
> LoadLegalEntityEmployeeList();
> if (!Page.IsPostBack)
> {
> gridLegalEntityEmployee.DataBind();
> }
> }
> private void LoadLegalEntityEmployeeList()
> {
> LegalEntityEmployee leEmployee = new LegalEntityEmployee();
> // Retrieve data from database
> gridLegalEntityEmployee.DataSource = leEmployee.SelectAll();
> // Bind it to Databind
> gridLegalEntityEmployee.DataBind();
> }
> ================================================== ==============
> I know there is a stupid mistake I made here, but I just cant't see it.
Any
> suggestion or recommeded is greatly appreciated. I really appriciate you
> guys help.
> Thanks a lot.
> Eddy

Saturday, March 24, 2012

please help + impersonate problem

Hi

Using this code I am try to imperosnate the user.

I did the sample page using this code, thats working fine. When i try place
this code into my existing application its working fine when I HARD CODED THE
USER NAME AND PASSWORD. if I pass the user name and password as variable
string, the imepersonate got failed.

Please help me.. its very urgent...

http://support.microsoft.com/defaul...B;EN-US;Q306158Hi Bala,

Can you post your code assigning the username and password? It's possible
you are making a minor syntax error or other mistake there. Also, you can
check in debug mode to make sure the username and password being passed are
the same as your hardcoded values.

--

Joshua Mitts
joshrm@.msn.com

"Bala" <Bala@.discussions.microsoft.com> wrote in message
news:A538D982-0140-435F-92A1-15FE30E119FE@.microsoft.com...
> Hi
> Using this code I am try to imperosnate the user.
> I did the sample page using this code, thats working fine. When i try
> place
> this code into my existing application its working fine when I HARD CODED
> THE
> USER NAME AND PASSWORD. if I pass the user name and password as variable
> string, the imepersonate got failed.
> Please help me.. its very urgent...
>
> http://support.microsoft.com/defaul...B;EN-US;Q306158

Wednesday, March 21, 2012

please help i need help urgently

Hi

I am working on asp.net application using vb.net as its language

I want to displaysystem date in a textbox and enter the value into sql database when a button "submit" is clicked

how can do it?when ever this webpage is started the textbox should automatically take the date in the text box and when i click a button submit that date should enter into the sql database

how can i do this?

please help i have an urgent project to be submitted on this plzzzz

You can get the current date by using System.DateTime.Now, however, I suggest you go through the video's and tutorials fromhttp://asp.net/learn to learn how to use ASP.NET before starting on any "urgent" projects.


Hi,

In the Page Load event

first check

if(!ispostback)

then

textbox.text=datetime.now.tostring()

also same for the submit button accept send the value in the insert query rather then textbox


You can also implement it in database level by using getdate()(for SQL server) function in the insert query or stored procedure whatever used by you to insert the value in databaseYou can also implement it in database level by using getdate()(for SQL server) function in the insert query or stored procedure whatever used by you to insert the value in database.


You can also implement it in database level by using getdate()(for SQL server) function in the insert query or stored procedure whatever used by you to insert the value in database.


"please help i have an urgent project to be submitted on this plzzzz"#

sounds like homework..

Friday, March 16, 2012

please help me to clear this error

hi, i am working in c# asp.net.

my cs:

public void confirm(Object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.Item.ItemType ==ListItemType.Item//e.Item.ItemType ==ListItemType.AlternatingItem)
{
LinkButton lb=(LinkButton)e.Item.Cells[0].FindControl("btndelete");
lb.Attributes["onclick"]="return(confirm('Confermi?'))";
}

}
i am using this coding to show confirm button while clicking the delete button.
this is my aspx:
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 160px; POSITION: absolute; TOP: 56px"
runat="server" OnDeleteCommand="cmddelete" DataKeyField="age" OnUpdateCommand="cmdupdate"
OnEditCommand="cmdedit" OnItemDataBound ="confirm" OnCancelCommand="cmdcancel" AutoGenerateColumns="False" OnItemCommand="insert"
ShowFooter="True" HeaderStyle-BackColor="#660033" HeaderStyle-ForeColor="white" BackColor="#660033"
ForeColor="#ffffff">

i did for edit,insert,delete allthe things correctly and works well, then i added this confirm delete, for this confirm i am getting the following error:

Compiler Error Message: CS0123: Method 'sqlserver.WebForm4.confirm(object, System.Web.UI.WebControls.DataGridCommandEventArgs)' does not match delegate 'void System.Web.UI.WebControls.DataGridItemEventHandler(object, System.Web.UI.WebControls.DataGridItemEventArgs)'

so please help me to solve this error,pleaseeeeeeeeeeeeeeeeTry Changing
public void confirm(Object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
To
public void confirm(Object source,System.Web.UI.WebControls.DataGridItemEventArgs e)
hi ferris, thanks for reply and i did modification as what u said, i am getting error in this,

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

public void confirm(Object source,System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType ==ListItemType.Item||e.Item.ItemType ==ListItemType.AlternatingItem)
{
//LinkButton btn=((LinkButton)e.Item.FindControl("delete"));
//btn.Attributes.Add("onclick","return confirm('Are you sure you want to delete this company?');");
LinkButton lb=(LinkButton)e.Item.Cells[0].FindControl("btndelete");
lb.Attributes["onclick"]="return(confirm('Confermi?'))";
//b.Attributes.Add("onclick","return confirm('Are you sure you want to delete this company?');");
}
}

please help me to rectify this error.
Hi,

Try changing

LinkButton lb=(LinkButton)e.Item.Cells[0].FindControl("btndelete");
lb.Attributes["onclick"]="return(confirm('Confermi?'))";

To

LinkButton lb = (LinkButton)e.Item.FindControl("btnDelete");
lb.Attributes.Add("onclick", "return(confirm('Confermi?'));

hth

please help me understand! ASP.Net - VB.NET

ok, so i took this sample form a site that offered to take the source code for the perpose of learning so i did. except that it is not working on my machine but its running where i got it from (the site).
could you please assist me knowing where the code went wrong?
the code is listed below:
<%@dotnet.itags.org. Page Language="VB" ClientTarget="downlevel" %>
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

myMessage.From = "webmaster@dotnet.itags.org." & Request.ServerVariables("SERVER_NAME")
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample from ASP 101!"
myMessage.Body = "This message was sent from sample code by " & _
"http://www.asp101.com. It is used to show people how " & _
"to send e-mail from an ASP+ page. This mail was sent " & _
"from " & Request.ServerVariables("SERVER_NAME") & ". " & _
vbCrLf & vbCrLf & _
"This email was sent to " & strEmail & "."

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "Your message has been sent to " & strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP+ Email Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:" runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@dotnet.itags.org.[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!" OnClick="btnSendMail_OnClick" runat="server" />
</form>

</body>
</html>

Thanks,
Rami Wahdan.

Hello,

I'm beginner also, but what I would try is:

Change line:
myMessage.From = "webmaster@." & Request.ServerVariables("SERVER_NAME")

into:
myMessage.From = "your@.email.com"

and delete these lines:
' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"


Rami,

it would also help if you would paste the exact error you are getting ... that will help in identifying your problem ...

cheers,

erik


ok so the error is:

Server Error in '/ASP.NET/email' Application.

The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com

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.Runtime.InteropServices.COMException: The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@. Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:
[COMException (0x8004020f): The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com][TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +1966108 System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +56[HttpException (0x80004005): The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com] System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +105 System.Web.Mail.CdoSysHelper.Send(MailMessage message) +3632 System.Web.Mail.SmtpMail.Send(MailMessage message) +102 System.Web.Mail.SmtpMail.Send(MailMessage message) +0 ASP.email_aspx.btnSendMail_OnClick(Object Source, EventArgs E) +325 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +232 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +5 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +31 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5157


Version Information: Microsoft .NET Framework Version:2.0.40607.16; ASP.NET Version:2.0.40607.16

hmm, the error seems rather clear, what exactly did you do to solve it?
>The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com
this means that the address you are sending to (a@.a.com) does not exist ...
to prevent this error to cause this page to display, you could add a Try ... Catch ... End Try statement around myMail.send(myMessage), like this:
Try
myMail.Send(myMessage)
Catch ex as Exception
End Try
Mind you, this only prevents the application to stop on the error, you should add code to handle the error properly
HTH
cheers,
erik