|
 |
aspx_beginners thread: reading from a textbox dynamically
Message #1 by soni29@h... on Sun, 14 Apr 2002 04:29:51
|
|
hi,
i had a slight problem on a page i'm working on, in the page there is a
textbox where the user can enter in a quantity, the default set value is
1. There is also a link on the page, this link goes to add.aspx and
passes the quantity in the url. so if the user puts 10 in the textbox the
url would look something like www.add?quantity=2 this way once page2 is
loaded it can read the url and calculate the cost. the problem is no
matter what number i set it to the default value 1 is always passes. here
is some of the code:
If objDataReader.Read() = True Then ' If Game
found then
Game.Text = "<Table border=0><td rowspan=3><img src='Images/" _
+ objDataReader("pic") + "'></td><td colspan=2><b>" +
objDataReader("ProductName") _
+ "</b></td><tr><td colspan=2>Description: " + objDataReader
("Description") _
+ "<tr><td colspan=2>Price: $" + CStr(objDataReader
("UnitPrice")) + "</td><tr>"
Game.Text += "</Table><br>"
Session("ItemID") = objDataReader("ProductID") ' Store
the product looking at in session
AddToCart.Text = "<a href='add.aspx?Item=" + Item + "&Quantity=" +
Quantity.Text + "'>Add to cart</a>"
Else
Game.Text = "No games found <br>"
End If
objDataReader.Close()
objConnection.Close()
Errors.Text = ""
Catch e as Exception
Errors.Text = "Connection failed. <br><br>Reason:" + e.ToString()
End Try
End If
End Sub
</script>
<HTML>
<HEAD>
</HEAD>
<BODY>
<asp:label id="Game" Runat = "Server" />
<form runat="server">
Enter Quantity Wanted: <asp:textbox id = "Quantity" columns = 2 text = 1
Runat = "Server" />
</form>
<asp:label id="AddToCart" Runat = "Server" />
<asp:label id="Errors" Runat="Server" />
</BODY>
</HTML>
Thanks.
Message #2 by Neeta.Ambekar@l... on Sun, 14 Apr 2002 16:36:33 +0530
|
|
hi
don't givr text value at design page ...set it in page load in Not
Postback event .
and if still giving same problem set autopostback event of textbox to true
let me know if it's work
Hope it will help u
Neeta
Message #3 by soni29@h... on Sun, 14 Apr 2002 21:40:56
|
|
hi,
thanks for the reply, but i'm a little confused by your answer, sorry i'm
new to asp.net. i thought postback was used if something is being posted
back to the page. what i was trying to do was send the quantity via the
url, so by default the amount is 1 on a page called show.aspx, if the user
types in 10 and clicks the link for adding to cart it should go to another
page, called add.aspx, which will read the url and get the quantity. any
ideas, or maybe i just misunderstood your answer, if so can you please
explain again?
Thanks.
>
hi
don't givr text value at design page ...set it in page load in Not
Postback event .
and if still giving same problem set autopostback event of textbox to true
let me know if it's work
Hope it will help u
Neeta
|
|
 |