Showing posts with label source. Show all posts
Showing posts with label source. Show all posts

Wednesday, March 21, 2012

please help me for this problem, as I havent done it before.

Hi, all

I want help for the below mentioned problems. PLease give example with source code. Please help me.


1. I have made upto this point. Now i want the functionality that when i enter the item orderd and discount the amount column should be updated as per the
following formula.
amount = rate*item orderd - discount

2. As the amount column updated the sub total should be changed.

3. as the user enter the taxes the grand total should also be changed.

Regards

sp_412000@dotnet.itags.org.yahoo.com



<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.OleDb" %>
<script runat="server" language="C#">
void Page_Load(Object src,EventArgs e)
{
OleDbConnection dbConn =
new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=/studynet/Authors2k.mdb;User Id=admin;Password=;" );
OleDbDataAdapter dbAdap = new OleDbDataAdapter("SELECT item_id,item_name,unit,rate,stock FROM product",dbConn);
DataSet ds = new DataSet();
dbAdap.Fill(ds,"product");
rept.DataSource = ds.Tables["product"].DefaultView;
rept.DataBind();
}
</script>
<html>
<form id="form1" runat="server">
<asp:repeater id="rept" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>Del</th>
<th>Item #</th>
<th>Name</th>
<th>Unit</th>
<th>Rate</th>
<th>Item Ordered</th>
<th>Discount</th>
<th>Amount</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox id="chk1" runat="server" />
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"item_id") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"item_name") %>
</td>
<td>
<#% DataBinder.Eval(Container.DataItem,"unit") %>
</td>
<td>
<#% DataBinder.Eval(Container.DataItem,"rate") %>
</td>
<td>
<asp:textbox id="txt1" runat="server" />
</td>
<td>
<asp:textbox id="txt2" runat="server" />
</td>
<td>
<asp:textbox id="txt3" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:repeater>
sub total: <asp:textbox id="subtot" runat="server" />
Taxes: <asp:textbox id="taxes" runat="server" />
Grand Total: <asp:textbox id="gtot" runat="server" />
</form>
</html>


the easiest way would be to add a button that performs the math functions when clicked
If you want it to be "automatic" then you would add a onchange eventfor the textboxes and have them do the approproate math when the textchanges
HTH

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

Please help me with FxCOP 1.32 and ASP.NET 2.0

Environment:
Microsoft Visual Studio 2005 Professional Edition
Microsoft Visual Source Safe 2005
FxCop 1.32
Project:
ASP.NET 2.0 C# Project
5 Developers
We are trying to implement FxCop into our build workflow and can't figure
out how best to tackle the task.
1) How can we automate FxCop in the build of the ASP.NET 2.0 project?
2) Do we need to use VSS to sync the FxCop rule set among developers?
3) Is there anything else you thing we should consider?
Will
Will G. Baldwin
Information and Educational Technology
Department of Communications
Kansas State University Research and Extension
Phone: 785-532-6270
E-Mail: wbaldwinREM()VE@dotnet.itags.org.ksu.eduHello Will,
In Visual Studio 2005, Code analysis FxCop is a build-in funtion for every
project:
1.Select the project in Solution Explorer.
2. On the Project menu, click Properties.
3. Click the Code Analysis tab.
4. Select Enable Code Analysis.
Here is an good article about this:
[url]http://msdn2.microsoft.com/en-us/library/y8hc3.aspx[/url]
For question about VSS, you may take a look at VSTS (visual studio team
system). You can use it instead of VSS and it is more powerful than VSS.
With VSTS, the administrator can specify the check-in rule based on the
code analysis or else. For example, a developer couldn't check in a file if
it hadn't passed the code analysis rule specified by administrator.
http://msdn.microsoft.com/vstudio/t...em/default.aspx
Hope this help,
Luke
Luke,
Thank for the help but when I follow you procedure I don't see a Code
Analysis tab.
On a Windows Project I get the following tabs:
Application
Build
Build Events
Debug
Resources
Settings
Reference Paths
Signing
Security
Publish
On a ASP.NET 2.0 Web Project I get the following tabs:
References
Build
Accessibility
Start Options
MSBuild Options
==================
No Code Analysis Tab !
==================
Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: Professional
Microsoft Visual Basic 2005 77626-009-0000007-41512
Microsoft Visual C# 2005 77626-009-0000007-41512
Microsoft Visual C++ 2005 77626-009-0000007-41512
Microsoft Visual J# 2005 77626-009-0000007-41512
Microsoft Visual Web Developer 2005 77626-009-0000007-41512
Crystal Reports AAC60-G0CSA4B-V7000AY
What am I doing wrong?
Thanks for the help!
- Will
"[MSFT]" <lukezhan@.online.microsoft.com> wrote in message
news:eZyQ%236gAGHA.4004@.TK2MSFTNGXA02.phx.gbl...
> Hello Will,
> In Visual Studio 2005, Code analysis FxCop is a build-in funtion for every
> project:
> 1.Select the project in Solution Explorer.
> 2. On the Project menu, click Properties.
> 3. Click the Code Analysis tab.
> 4. Select Enable Code Analysis.
> Here is an good article about this:
> [url]http://msdn2.microsoft.com/en-us/library/y8hc3.aspx[/url]
> For question about VSS, you may take a look at VSTS (visual studio team
> system). You can use it instead of VSS and it is more powerful than VSS.
> With VSTS, the administrator can specify the check-in rule based on the
> code analysis or else. For example, a developer couldn't check in a file
> if
> it hadn't passed the code analysis rule specified by administrator.
> http://msdn.microsoft.com/vstudio/t...em/default.aspx
> Hope this help,
> Luke
>
Code Analysis only comes with Visual Studio .Net 2005 Team Suite.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
<madhattan@.newsgroups.nospam> wrote in message
news:ey9ef6kAGHA.2044@.TK2MSFTNGP12.phx.gbl...
> Luke,
> Thank for the help but when I follow you procedure I don't see a Code
> Analysis tab.
> On a Windows Project I get the following tabs:
> Application
> Build
> Build Events
> Debug
> Resources
> Settings
> Reference Paths
> Signing
> Security
> Publish
> On a ASP.NET 2.0 Web Project I get the following tabs:
> References
> Build
> Accessibility
> Start Options
> MSBuild Options
> ==================
> No Code Analysis Tab !
> ==================
> Microsoft Visual Studio 2005
> Version 8.0.50727.42 (RTM.050727-4200)
> Microsoft .NET Framework
> Version 2.0.50727
> Installed Edition: Professional
> Microsoft Visual Basic 2005 77626-009-0000007-41512
> Microsoft Visual C# 2005 77626-009-0000007-41512
> Microsoft Visual C++ 2005 77626-009-0000007-41512
> Microsoft Visual J# 2005 77626-009-0000007-41512
> Microsoft Visual Web Developer 2005 77626-009-0000007-41512
> Crystal Reports AAC60-G0CSA4B-V7000AY
> What am I doing wrong?
> Thanks for the help!
> - Will
> "[MSFT]" <lukezhan@.online.microsoft.com> wrote in message
> news:eZyQ%236gAGHA.4004@.TK2MSFTNGXA02.phx.gbl...
>
Yes, For a full production edition compare:
http://msdn.microsoft.com/vstudio/p...re/default.aspx
Luke