|
Hi. got a project where you enter a number of tickets, the number of tickets, and then if you add a check box, the code for the credit card, then select from a combo box. the general price for this event is $15 and the awards ceremony is $25. then the hyper link is invisible until you click the submit button, which then will give the user a wecome message, and the general details. then the hyperlink is visible agaion. my problems, and questions are. know how to evaluate a checkbox and radio buttons, but how to evaluate a checkbox with a variable, then add that to the calculation. 2. to help me get the correct calculations. 3. to help me fix the errors. will paste below. any help, suggestions, or code snippets or samples would be fine. cheers Marvin.
'Program: Tickets
'Programmer: Marvin Hunkin
'Date: Monday Febuary 23 2009
'Description: Selling tickets For A Rodeo
Partial Class Tickets
Inherits System.Web.UI.Page
Protected Sub btnSubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmitButton.Click
'Declare Variables
dim decTickets as Decimal = 15
dim decAwards as Decimal = 25
dim decAmountDue as Decimal = 0.0
dim intCounter as Integer = 0
dim tbNumerTextbox as TextBox
dim tbAmountDueTextBox as TextBox
dim decTotalAmount as decimal = 0.0
'Add One to Counter
intCounter += 1
'Calculate Total amount
decAwards = 25
if chkAwardsCheckBox.Checked = True
decTotalAmount =decAmountdue * decTickets + decAwards
else
decTotalAmount = decAmountDue + decTickets
end if
'Format Text Boxes
tbNumerTextbox.text = intCounter.ToString()
tbAmountDueTextBox.text = decAmountdue.ToString("C")
tbNumberTextBox.Focus
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
if ispostback then
'Do Nothing
else
dim liItemOnetext as New ListItem
dim cboCreditCard as DropDownList
liItemOne.text= "VISA"
liItemOneltext = "AMEX"
liItemOneltext= "MasterCard"
cboCreditCard.items.add(liItemOne)
end if
dim intCounter as Integer = 0
dim decTickets as Decimal = 15
dim decAwards as Decimal = 25
dim decAmountDue as Decimal = 0.0
dim tbNumberTextbox as TextBox
dim tbAmountDueTextBox as TextBox
'Display Information
intCounter = session("savedNumberOftickets")
decAmountDue = session("savedAmountDue")
decAmountdue = decTickets + decAwards
session("SavedNumberOfTickets") = intCounter
session("SavedAmountDue") = decAmountDue
End Sub
end class
b
|
|
|
|
|
Again, you are overusing the session object. Why ?
Are you trying to work through a book, or is this homework ? If it's homework, I'm surprised you have several projects at once. You're obviously a beginner, try to stick to one project until you understand the issues related to that, before moving on.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
HI. well the programming book example, showed me about session variables, so need to use this for this exercise and how to get it to work, and also, got errors,, using variables, before it has been assigned. so need help or code snippets how to do this. not to do it for me, but to help me how to fix the errors, and how to maybe sample code to evaluate a checkbox and a variable. and how to invoke the link to be invisible, then when i calculates, then to display the link again and make it visible. well need session variables, to dhow the total amount and the number of tickets people purchased. so sorry about this. cheers and get bakc to me asap.
|
|
|
|
|
Hi. forgot to add, yes working through a programming book. cheers Marvin.
|
|
|
|
|
HI. a blind programming student from Australia and use the jaws for windows screen reader from http://www.freedomscientific.com. my problem is, the project is a standard login form in visual web developer express 2005. and the user types in their name, e-mail, user name, password, then confirm password. if the 2 passwords match, then a label with a welcome message and the name of the user taken from the text box. if you do not have the passwords matching, you get an error message. now, for some stupid reason jaws is not reading me the welcome message and the user name. so wondering, what am i doing wrong? how to get this to read correctly. any access technology specialists or users, who are blind or vision impaired here on this forum. will paste the code for the project below. any ideas, suggestions or work arounds or fixes are welcome. cheers Marvin.
'Program: Login
'Programmer: Marvin Hunkin
'Date: Monday Febuary 23 2009
'Description: Login Form and compare two password strings
Partial Class Login
Protected Sub btnSubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmitButton.Click
'Declare Variables
Dim strPassword As String = "Password"
Dim strConfirmPassword As String = "Password"
'If password and confirm passwords are same, then display welcome message
If tbPasswordTextBox.Text = tbConfirmPasswordTextBox.Text Then
lblMessageLabel.Text = "Hello " & tbNameTextBox.Text & ""
Else
tbPasswordTextBox.Text = ""
tbConfirmPasswordTextBox.Text = ""
lblMessageLabel.Text = "The Passwords You entred do Not Match! Please Try Again!("")"
tbNameTextBox.Focus()
End If
End Sub
End Class
|
|
|
|
|
StarTrekCafe wrote: now, for some stupid reason jaws is not reading me the welcome message and the user name. so wondering, what am i doing wrong? how to get this to read correctly.
I didn't get what is your actual problem. Its seems working fine.
BTW : How this question comes into ASP.NET Forums.
As you are new in CP, please read the forum guideline. and post in proper forum.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Abhijit Jana wrote: I didn't get what is your actual problem
I'm guessing the HTML output is not accessibility compliant as his screen reading software doesn't read part of the the content on the web page.
Abhijit Jana wrote: How this question comes into ASP.NET Forums.
Because he is asking about what he did wrong in making the ASP.NET page accessibility compliant.
Abhijit Jana wrote: and post in proper forum
As far as I can see he is posting in the proper forum.
|
|
|
|
|
HI. well my problem is my screen reader is not reading me that welcome message and the name of the user, and it does relate to asp dot net, because that was one of the exercises in the web programming chapter of the vb programming book. now, wondering, if it being hidden by some type of thing, and wonder if i need to use a separate text box or status bar. cheers Marvin.
|
|
|
|
|
this is my code
public decimal OrderTotal;
SqlParameter parameterOrderTotal = new SqlParameter("@OrderTotal", qlDbType.Money);
parameterOrderTotal.Direction = ParameterDirection.Output;
myCommand.SelectCommand.Parameters.Add(parameterOrderTotal);
retreive this value by
myOrderDetails.OrderTotal = (decimal)parameterOrderTotal.Value;
some times ite work fine but sometime its show errror Specified cast is not valid.
Tahnx
|
|
|
|
|
You need to check for a null value (or DBNull.Value) before casting it.
|
|
|
|
|
I am using Grid View control in asp.net (3.5). I am passing Grid View value from one page to another. In another page i want to edit that value. I am facing a problem while editing as it's retaining old value in Update command.
Pls. help
modified on Sunday, March 15, 2009 4:23 AM
|
|
|
|
|
OK, so you expected to post this in the VB forum and get help ? Wow. Even now, I don't see how we can help you. What value are you passing ? How are you passing it ? Why are you editing the value in the new page ? What do you mean, it's retaining the old value ? You haven't given anything like an explanation that gives us info we need to try to understand and help you.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
maybe a little bit of code and value parameters will help you more
|
|
|
|
|
hello sir/madam
i have following code for updating database via datagrid control,,but it produces an error..can anybody tell me how to deal with this kind of error..
]]>
]]>
SqlConnection connector = new SqlConnection(@"Server=localhost;Integrated Security=SSPI;Database=cms");
String strsql;
void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindDataGrid();
}
void BindDataGrid()
{
SqlCommand cmdsql = new SqlCommand("Select * from studentmarksentry", connector);
connector.Open();
unittest1marksentry_datagrid.DataSource = cmdsql.ExecuteReader();
unittest1marksentry_datagrid.DataBind();
connector.Close();
}
void CancelCommand(Object sender, DataGridCommandEventArgs e)
{
unittest1marksentry_datagrid.EditItemIndex = -1;
BindDataGrid();
}
void EditCommand(Object sender, DataGridCommandEventArgs e)
{
unittest1marksentry_datagrid.EditItemIndex = e.Item.ItemIndex;
BindDataGrid();
}
void UpdateCommand(Object sender, DataGridCommandEventArgs e)
{
int regd_num;
String txtvalueholder;
if (IsValid)
{
regd_num=(int)unittest1marksentry_datagrid.DataKeys[e.Item.ItemIndex];
TextBox txtmarksentry = (TextBox)e.Item.FindControl("txtmarksentry");
txtvalueholder = txtmarksentry.Text;
strsql = "update studentmarksentry set MarksObtained=@marksentry where Regdno=@register";
SqlCommand cmdsql = new SqlCommand(strsql, connector);
cmdsql.Parameters.Add("@marksentry", txtvalueholder);
cmdsql.Parameters.Add("@register", regd_num);
connector.Open();
cmdsql.ExecuteNonQuery();
connector.Close();
unittest1marksentry_datagrid.EditItemIndex = -1;
BindDataGrid();
}
}
<title>Unit-Test 1 marks Entry form
<asp:datagrid id="unittest1marksentry_datagrid" autogeneratecolumns="false" oncancelcommand="CancelCommand" oneditcommand="EditCommand" xmlns:asp="#unknown">
OnUpdateCommand="UpdateCommand" runat="server">
<columns> <asp:boundcolumn headertext="Register No" datafield="Regdno" readonly="true">
<asp:boundcolumn headertext="First Name" datafield="First name" readonly="true">
<asp:boundcolumn headertext="Middle Name" datafield="Middle name" readonly="true">
<asp:boundcolumn headertext="Last Name" datafield="Last name" readonly="true">
<asp:templatecolumn>
<headertemplate>
Marks Obtained
<itemtemplate>
<%#DataBinder.Eval(Container.DataItem,"MarksObtained") %>
<edititemtemplate>
<asp:textbox id="txtmarksentry" text="<%#DataBinder.Eval(Container.DataItem," marksobtained")="" %>"="">
runat="server">
<asp:comparevalidator id="unittest1marksentry_comparevalidator" controltovalidate="txtmarksentry">
Display="Dynamic" Text="must be a number" Operator="DataTypeCheck" Type="Integer"
runat="Server">
<asp:editcommandcolumn edittext="Edit" updatetext="Update" canceltext="Cancel">
here my database name is cms and try to update the marks obatined column but i get following error
:Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
ok
waiting for the reply.
|
|
|
|
|
Buy a basic programming book and read it. Don't post so much code that no-one will bother reading it.
rosae619 wrote: :Index was out of range. Must be non-negative and less than the size of the collection.
It means what it says. Look at the code where the debugger breaks. Is index < 0, or greater than the collection ? Never access a collection without first making sure the index you're about to use is valid. Read error messages, and then think about what they say. They mean what they say.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
this is my question i want to put the functionality of onblur method of textbox is not in javascript but in c# but i am unable to find any similar or working functionality.
-------------------xxx-----Have any ideas----------------xxxxxxxxxxx-------------------
thanks.
|
|
|
|
|
There's a reason for this. The reason is that it would be idiotic for this to exist. You need to understand how web applications work, and you plainly do not. A web page that reloaded itself every time a textbox lost focus, would really, really suck. You can use C# code by making an AJAX call, assuming you know anything about AJAX.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
can you please more clarify it ..well i have ajax tools and extenders but dont know which one to use and any article for me is more helpful.
|
|
|
|
|
Alok sharma ji wrote: well i have ajax tools and extenders
Put your textbox inside an updatepanel. Set AutoPostBack=true and hook the TextChanged event handler. You can see the event fires on blur.
|
|
|
|
|
See, I would have told him how to write actual code, instead of using a framework that he doesn't understand in any way. But, your reply probably helped him more, I would have just tried to force him to consider becoming a programmer.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: I would have just tried to force him to consider becoming a programmer.
Agree 100%. I would have done that. OP said, he already started AJAX framework and I thought obvious answer would be helping on that. I am not sure how much he would have followed if I answer him in a different way.
|
|
|
|
|
Onblur can only be generated if the page is posted back.
In client server architecture, when a response is sent to the client, there is no connection between the client and the server. Thus when the page is posted back, that means another request is been made to the server with some postback info.
You can create an HTTPHandler to generate server side event, but to post back your page automatically when onBlur event of a textbox occurs, you need to do it through javascript.
Just do a postback of the page to your handler..
Hope you understand!!!!
|
|
|
|
|
thanks now i get it clearly. thanks again
|
|
|
|
|
I don't know why all the LinkButton in my C#.net website cann't work,
It means that if i clicked the button just like i have nothing to do with it.
Can someone help me?waiting online
the browser has not any problem.
Now i know what cause this problem,but i don't know how to solve.
my website reference a outside javascript file,the file content is:
var imgObj;
function showImage(imgsrc)
{
if(imgObj!=null) {
document.body.removeChild(imgObj);
}
imgObj=document.createElement("div");
imgObj.setAttribute("id","imgDiv");
imgObj.setAttribute("align","center");
imgObj.style.border="0";
imgObj.style.position="absolute";
var X=event.x;
if(X<=screen.width*41/100)
X=X+100;
else if(X>=screen.width*59/100)
X=X-200-350;
else
X=screen.width*59/100;
imgObj.style.left=X;
imgObj.style.top="30%";
imgObj.style.marginTop=-75+document.documentElement.scrollTop+"px";
imgObj.style.zIndex="1000";
imgObj.innerHTML="<img src='"+imgsrc+"' onerror='return true' height=400 width=350 />";
document.body.appendChild(imgObj);
}
function hideImage()
{
document.body.removeChild(imgObj);
imgObj=null;
}
this script is to show the bigger image onmouseover,but i don't know why it can cause this problem.
modified on Saturday, March 14, 2009 10:05 PM
|
|
|
|
|
1 - See the event handlers are hooked correctly.
2 - Take the viewsource of that page and see how it is rendered.
3 - Make sure you have JS enabled browser.
|
|
|
|