|
That function is in ShoppingClass class.
|
|
|
|
|
this is the function in ShoppingCart class.
<pre>
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Public Class ShoppingCart
Private _cart As List(Of CartItem)
Public Sub New()
_cart = New List(Of CartItem)()
End Sub
Public Function GetItems() As List(Of CartItem)
Return _cart
End Function
Public Sub AddItem(ByVal id As String, ByVal name As String, ByVal price As Decimal)
Dim itemFound As Boolean = False
For Each Item As CartItem In _cart
If Item.ID = id Then
Item.Quantity += 1
itemFound = True
End If
Next
If Not itemFound Then
Dim item As CartItem
item = New CartItem(id, name, price, 1)
_cart.Add(item)
End If
End Sub
Public Sub UpdateQuantity(ByVal index As Integer, ByVal quantity As Integer) 'update quantity function
Dim item As CartItem
item = _cart(index)
item.Quantity = quantity
End Sub
Public Sub DeleteItem(ByVal index As Integer) 'delete item function
_cart.RemoveAt(index)
End Sub
Public ReadOnly Property Count() As Integer
Get
Return _cart.Count
End Get
End Property
End Class
</pre>
|
|
|
|
|
If we like to took an inbox page of rediff or any other page login page will dispaly for any site.How we make it for an aspx page also.If a user took a page http://eSIMSys/chatpage.aspx the login page will dispaly after login only user can access the chatpage.How is it possible.We are using form authentication.
|
|
|
|
|
I *think* you're asking how to enforce login ? The way I do that, is to make all pages that are protected, derive from a base class which checks if the user is logged in, and, if not, redirect to the login page. I suspect if you're using built in stuff, there'd be a config setting for the login page and it would redirect, but I prefer to write code.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
bellow code has this Error: cannot implicity convert type login to System.Web.UI.WebControls.Login
protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)<br />
{<br />
if (e.CurrentStepIndex == 0)<br />
{<br />
System.Web.UI.WebControls.Login l =((Login)Wizard1.FindControl("Login1"));<br />
<br />
if (Membership.ValidateUser(l.UserName, l.Password))<br />
{<br />
FormsAuthentication.SetAuthCookie(l.UserName, l.RememberMeSet);<br />
e.Cancel = false;<br />
}<br />
else<br />
{<br />
l.InstructionText = "";<br />
l.InstructionTextStyle.ForeColor = System.Drawing.Color.Red;<br />
e.Cancel = true;<br />
}<br />
}<br />
else<br />
{<br />
if (!User.Identity.IsAuthenticated)<br />
{<br />
e.Cancel = true;<br />
Wizard1.ActiveStepIndex = 0;<br />
}<br />
<br />
}<br />
}
How i can solve this error?
Thank you,
Hoda
|
|
|
|
|
WEll, it usually helps if you tell us what line has the error. In this case, tho, I think it's clear.
Saba02 wrote: System.Web.UI.WebControls.Login l =((Login)Wizard1.FindControl("Login1"));
In the first case you specify the full namespace of the control, in the second, you do not. Obviously you have another class called Login somewhere, and that is in scope, so you need to full scope the login control on the right, so the two sides both point to the same object, instead of two different objects with the same name.
Consider also renaming your Login class so this doesn't happen again.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Following on from my other question, I have a GridView which is bound to a SqlDataSource. It has several pages. In my PageLoad() event handler I can get a count of how many pages are on the gridview by the GridView.PageCount property. If that's the case, I'd like to iterate through each page and find a row from the GridView.DataKeys property with a column matching a particular value and select the row.
I've tried iterating through each page by setting the GridView.PageIndex property and then getting the GridView.DataKeys property but the latter isn't updated - it only gets the first (displayed) page's set of values.
|
|
|
|
|
Have you tried looping through the rows after binding.
<br />
GridView1.DataBind()<br />
<br />
For Each row In GridView1.Rows()<br />
'Do whatever<br />
Next <br />
<br />
<div class="ForumSig">Don't you just hate coming up with something to put here?</div>
|
|
|
|
|
Hi
I have a GridView on my ASP.NET 2.0 page which I've populated from a SqlDataSource. It all works great but now I want to use the same page and pass the ID (or primary key value) into the page via a parameter. I want the Gridview to then select the entry with the corresponding ID in the GridView.
In other words, if I open the page without passing a parameter, the gridview shows the data as usual (I've used a select column which highlights the selected row).
If I pass a parameter in, I want the correct page in the GridView to be displayed along with the correct row highlighted.
Is this possible?
Thanks
|
|
|
|
|
Yes, this is possible. I would recommend using a Details View instead of a Grid View, for the simple reason that the Details View is designed to show 1 record whilst the Grid View is for many.
To do this, in the Grid View set the select function to something like Server.Transfer("DetailsViewPage.aspx?ID="+IDFieldFromGridView)
Then in in the Details View page, do:
<br />
If Request.QueryString("ID") = ""<br />
Server.Transfer("GridViewPage.aspx")<br />
End If<br />
<br />
'Pragmatically set params for Details View<br />
Don't you just hate coming up with something to put here?
|
|
|
|
|
I am trying a URL redirection by wrting a code in Application_BeginRequest
in global.asax and using a rule.xml file
Below is the scnerio
#1 user enters a path http://sitename/project/Article06/issue6
This particlar folder "Article06/issue6"is not on the vistual direcory or on website. In Application_BeginRequest i read this path and if the path is equal to Article06/issue6 i redirect him to some other page.
The code works fine when it is executed from visual studio. But when i deploy this in IIS it does'nt even go to Application_BeginRequest method of global.asax it gives me 404 error
Any idea why it is not working on IIS and how can I solve it
Regards,
Pavas
|
|
|
|
|
Sounds like your code is not running, is ASP.NET configured on the machine and the website properly configured ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have noticed that when you enter a path which do not exist on the virtual directory or website. It never comes to Applicaion_BeginRequest method.
Regards,
Pavas
|
|
|
|
|
Are you sure that the file extension you supplied are handled by ASP.NET worker process.
|
|
|
|
|
There was an issue with the IIS and asp.net setup...got it resolved..
sorry for the trouble
Regards,
Pavas
|
|
|
|
|
I wonder if there is an easy way to "extend" the DragPanelExtender in the Ajax Toolbox to carry out one more function. What I want to do is have a postback to the server or send a URL to the server that contains the X & Y position where the DragPanel was dropped.
Essentially what I am trying to to do is allow an ASP.Net panel containing a textbox to be dragged and dropped on one of a dozen or so absolutely positioned images, and the codebehind file to take the appropriate action depending upon the image on which the panel was dropped.
Thought this would be simple, and there are some examples in VS2008 but I am stuck with needing to code this in VS2005
Any sugestions and help would be appreciated
Many Thanks
|
|
|
|
|
Greetings!!!
How do we mimic following ADO Recordset object Property/methods/events in ADO.NET
Requery
Resync
Bookmark
Activeconnection
getBookmark()
setBookmark(currentBM)
Delete ()
close ()
getStatus()
getDataSource()
DataMember()
Update(Fields,Values)
ActiveConnection()
Need urgent HELP!!!!!
Thanks in advance
|
|
|
|
|
Member 4357460 wrote: Need urgent HELP!!!!!
A good first step is to ask in the right forum.
ADO.NET is disconnected, it works differently to ADO.
I'm sure there are books on this, and article, too.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes I agree...with you..
but my current project demands the simulation of ADO Recordset object Property/methods/events in ADO.NET...
I need wrapper class...
thanks
|
|
|
|
|
Why does it require that ? You really can't have it, and because ADO.NET is disconnected, trying to simulate the connectedness of ADO is going to result in a LOT of database traffic.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am trying to come up with a way to use Uri.EscapeDataString() and Uri.UnescapeDataString() in a templated GridView so I can put tags into text that is uploaded into a SQlServer table, so that the formatted text can be put into a label on a web form. By escaping the data, I do not want to have ValidateRequest="false" set on the page header. I am trying to keep sqlInjection attacks from possibly happening on a database editing form.
My goal on this page is to drop one of the html editors onto the page to make the textbox become a word-like editor so the client can format data to be displayed on the website.
Thanks for any suggestions
Tom
|
|
|
|
|
Hi all,
I have this fuction in my class that named Insert:
public void Insert(int Productid, <big>double Price</big>, int Quantity,string Productname, string Productimageurl)<br />
{<br />
int itemindex = itemindexofid(Productid);<br />
<br />
if (itemindex == -1)<br />
{<br />
cartitem newitem = new cartitem();<br />
newitem.Productname = Productname;<br />
newitem.Productid = Productid;<br />
newitem.Quantity = Quantity;<br />
newitem.Price = Price;<br />
newitem.Productimageurl = Productimageurl;<br />
items.Add(newitem);<br />
}<br />
else<br />
{<br />
items[itemindex].Quantity += 1;<br />
}<br />
lastupdate = DateTime.Now;<br />
}
Now i want use this function as bellow:
protected void btnAddToCart_Click(object sender, ImageClickEventArgs e)<br />
{<br />
<big>string Price = double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text).ToString("0.00");</big><br />
string ProductName = ((Label)DataList1.Controls[0].FindControl("Book_NameLabel")).Text;<br />
string PictureURL = ((Label)DataList1.Controls[0].FindControl("picLabel")).Text;<br />
int ProductID = Convert.ToInt32(Request.QueryString["idLabel"]);<br />
if (Profile.cart == null)<br />
{<br />
Profile.cart = new ShopCart.wroxshoppingcart();<br />
}<br />
Profile.cart.Insert(ProductID, Price,1,ProductName,PictureURL);<br />
Server.Transfer("ItemIndex.aspx"); <br />
}
I have problem with Price,i convert price to string ,then i want send price that be converted to string to function, that the type of price in my function is double.
How i can do this work?
thank you
Hoda
|
|
|
|
|
Why did you convert it to string in the first place?
You can replace this line:
string Price = double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text).ToString("0.00");
with this:
double Price = double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text);
|
|
|
|
|
To build a little on hspc reply
double d = 0;
bool DoubleParseSuccessful;
try
{
DoubleParseSuccessful = double.TryParse(double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text).ToString("0.00"), out d);
}
catch (FormatException Fex)
{
DoubleParseSuccessful = false;
}
if (DoubleParseSuccesful == false)
{
}
This will prevent your application from crashing if someone posts false data back to the server by changing the PriceLabel.
|
|
|
|
|
Why not just call tryparse, and not bother with converting back and forth ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|