i want create purchase cart in list view and use stepper for change count of products and change online price but i do not know what to send product id to server.my code:
You can retrieve the model using the control's binding context. Then access the corresponding ID or other properties there:
private void OnStepperValueChanged(object sender, ValueChangedEventArgs e)
{
Stepper stepper = sender as Stepper;
var model = stepper.BindingContext;
// model.id
// model.Count
}
To get the current selected value in the stepper you can just:
void OnStepperValueChanged(object sender, ValueChangedEventArgs e)
{
double count = e.NewValue;
}
Related
I created a behavior 'RequiredValidationBehavior' and applied to one of the entry fields in XAML page.
It works as, if the entry field is empty, the placeholder color becomes red, thus indicating the mandatory field. This works fine.
The issue I am facing is with the button on the page, where it should to be disabled if this entry field is empty and enabled if the entry field has some value.
I want to achieve this using the behavior I created.
Thanks for the responses in advance.
You can try with below code:
public void entryTextChanged(object obj, EventArgs args)
{
if (entry.Text.Length > 0)
button.IsEnable= true;
else
button.IsEnable = false;
}
And just assign this event to Entry on "TextChanged" Event.
private void EntryMessage(object sender, EventArgs e)
{
var keyword = Message.Text;//your entry
if (string.IsNullOrEmpty(keyword))
{
OnAddBT.IsEnabled = false;//your button
}
else
{
OnAddBT.IsEnabled = true;//your button
}
}
Where can I create this object in the asp.net lifecycle methods without receiving an out of range exception. Right now the only place that I can actually get a resource collection containing values is in onreasourcefetched method for webschedule info. But I need to do this before webscheduleinfo is created and it's views are populated with users.
protected void Page_Init(object sender, EventArgs e)
{
ResourcesCollection resources = WebScheduleInfo1.VisibleResources;
int count = resources.Count;
Resource obje = (Resource)resources.GetItem(1);
string name = obje.Name;
resources.Clear();
resources.Add(obje);
this.WebScheduleInfo1.ActiveResourceName = name;
}
You are getting a count of resources but you are not checking to make sure that count is greater than 0.
(Resource)resources.GetItem(1) will fail unless the resources collection has at least 2 items in it.
The collection is 0 based, so if you want the first item do something like this:
protected void Page_Init(object sender, EventArgs e)
{
ResourcesCollection resources = WebScheduleInfo1.VisibleResources;
int count = resources.Count;
if( count > 0 )
{
Resource obje = (Resource)resources.GetItem(0);
string name = obje.Name;
resources.Clear();
resources.Add(obje);
this.WebScheduleInfo1.ActiveResourceName = name;
}
}
I have a Devexpress Gridview where item and it's price is displayed.
Editing is enabled.
I use rowupdating event so inorder to check if the price updated is higher than a normal value.
if so, i cancel edit by
e.Cancel = true;
ASPxGridView1.CancelEdit();
the next thing i want is to popup a aspx popupcontrol requesting a password inorder to proceed with higher amount within the rowupdating event.
the popcontrol will contain a password textbox and a button.The remaining procces will be carried out by button click function
eventhough i called popcontrol
ASPxPopupControl2.ShowOnPageLoad = true;
the pop doesn't show up......why is this so..
here is my over all code..
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
string msg;
double new_amt = double.Parse(e.NewValues["Amount"].ToString());//-->gets new amount
string type= e.OldValues["Type"].ToString();//-->gets the item
double refer_amt=Misc_functions.Get_Item_Amount(type,out msg);//--this function fetches the normal amount for a particular item
if (new_amt > refer_amt)
{
e.Cancel = true;
ASPxGridView1.CancelEdit();
ASPxPopupControl2.ShowOnPageLoad = true;
}
}
Basically i need a password authentication if an amount edited is a higher than a normal value.
any ideas??
This cannot be done using the server code. The best solution is to create a custom java script variable within the RowUpdating event handler and check its value in the ASPxGridView's client side EndCallback event handler. I.e.
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{ ...
gridView.JSProperties["cpShowPopup"] = true;
...
}
EndCallback = function(s,e) {
if(typeof(s.cpShowPopup) != 'undefined') {
popup.Show();
}
}
Hope, this helps.
I have a form where users can subscribe and unsubcribe to my email list. so far, i have the subscribe button working fine "add member" function. Now i need help with my "delete member " function (unsubscribe button). it will allows the user to delete their record from the database. When I run the code and click the "unsubscribe" button, i can't get the logic correct so that it will delete the user's record if it exisit. thanks for your help!
here's the code i'm using for the subscribe and unsubscribe buttons -----------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class joinmailinglist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void addMember(object sender, EventArgs e)
{
// here you are defining the classes for the database and the linq
mailinglistClassDataContext Class = new mailinglistClassDataContext();
mailinglistMember member = new mailinglistMember();
// Now we are going to add the data to the member
// Here we are going to let the system define a GUID for the unique user ID
member.memberID = new Guid();
// here we are going to capture the user inputs and we are going to set these to lower case especially the email so that we can do a proper comparison later.
member.fname = txtFirstName.Text;
member.lname = txtLastName.Text;
member.email = txtEmail.Text;
// Here we are going to create the URL so we can later remove the user if they decide to opt out.
member.removeurl = "http://removeuser.aspx?code=" + member.memberID.ToString();
// Here we are going to use a LINQ query to search the class of mailinglistmembers for any emails that contain equal values of the text field and select it.
var duplicatecheck = from emails in Class.mailinglistMembers
where emails.email.Contains(txtEmail.Text)
select emails;
// Here we are going to check that the count of duplicate is equal to zero. If so then we are going to insert the member information into the class and then submit the changes to the database.
if (duplicatecheck.Count() == 0)
{
Class.mailinglistMembers.InsertOnSubmit(member);
Class.SubmitChanges();
}
else
{
lblDuplicate.Text = "Hey you have already entered your information.";
}
}
protected void deleteMember(object sender, EventArgs e)
{
// here you are defining the classes for the database and the linq
mailingListClassDataContext Class = new mailingListClassDataContext();
mailinglistMember member = new mailinglistMember();
// here we are going to capture the user inputs and we are going to set these to lower case especially the email so that we can do a proper comparison later.
member.email = txtEmail.Text;
// Here we are going to use a LINQ query to search the class of mailinglistmembers for any emails that contain equal values of the text field and select it.
var deleterec = from emails in Class.mailinglistMembers
where emails.email.Contains(txtEmail.Text)
select emails;
// Here we check if the record exisits
if (deleterec.Count() == 0)
{
Class.mailinglistMembers.DeleteOnSubmit(member);
Class.SubmitChanges();
Response.Redirect("frm_confirmation.aspx");
}
else
{
lblDelete.Text = "No record exsists!";
}
}
}
Try the below code.
string mailAddress = txtEmail.Text.Trim().ToLower();
using (var db = new mailingListClassDataContext())
{
var records = from e in db.mailinglistMembers
where e.mail == mailAddress
select e;
if (records != null)
{
db.mailinglistMembers.DeleteAllOnSubmit(records);
db.SubmitChanges();
Response.Redirect("frm_confirmation.aspx");
Response.End();
}
else
{
lblDelete.Text = "No records exists!";
}
}
You may have meant to do this:
var deleterec = Class.mailinglistMembers
.FirstOrDefault(emails => emails.email.Contains(txtEmail.Text));
if (deleterec != null)
{
Class.mailinglistMembers.DeleteOnSubmit(deleterec);
Class.SubmitChanges();
Response.Redirect("frm_confirmation.aspx");
}
Looks like someone tried to add on to the code I origianlly posted in my article on code project. Not sure if you've read the article but it might help solve your problem and understand how it was intended to work. A link would return you to a removal page that would and capture the GUID. I used the GUID as the identifyer to remove the user. Original Article
I've a asp.net page which uses multi select checkboxlist(say having 10 checkboxes)....for example
I've enabled AutoPostBack for any change in checkboxlist.
Initially,out of 10, 3 are selected.
On top of this, if user checks another checkbox, how do I know which particular checkbox has been checked by the user and retrieve its value?
Thanks.
for (int i=0; i<checkboxlist1.Items.Count; i++)
{
if (checkboxlist1.Items[i].Selected)
{
}
}
protected void Page_Load(object sender, EventArgs e)
{
string name = Request.Form["__EVENTTARGET"] ?? String.Empty;
if (name.IndexOf("CheckBoxList1") != -1)
{
int last = name.LastIndexOf("$") + 1;
int index = Convert.ToInt32(name.Substring(last, name.Length - last - 1));
if (CheckBoxList1.Items[index].Selected)
{
string text = CheckBoxList1.Items[index].Text;
string value = CheckBoxList1.Items[index].Value;
}
}
}
If you want to know which last checkbox was clicked on the server side, you should enable AutoPostBack for each checkbox and capture the values accordingly. If you have the flexibility to find out the last checkbox click on the client side, then you should implement a javascript "onclick" event for each checkbox to capture the value on each checkbox and simply update the checked value in a hidden variable and pass it back to the server on postback