I want to add PayPal Donate button to my application, but I don't know how. I tried to search in google and on PayPal site, but I didn't found a solution. Do you have any suggestions ?
I found solution on that site : http://www.gorancic.com/blog/net/c-paypal-donate-button :
private void btnDonate_Click(object sender, System.EventArgs e)
{
string url = "";
string business = "my#paypalemail.com"; // your paypal email
string description = "Donation"; // '%20' represents a space. remember HTML!
string country = "AU"; // AU, US, etc.
string currency = "AUD"; // AUD, USD, etc.
url += "https://www.paypal.com/cgi-bin/webscr" +
"?cmd=" + "_donations" +
"&business=" + business +
"&lc=" + country +
"&item_name=" + description +
"¤cy_code=" + currency +
"&bn=" + "PP%2dDonationsBF";
System.Diagnostics.Process.Start(url);
}
Related
i would like to pass data from a text box in one user control and store it inside of a variable in another user control.
so far I've created an instance of the class that i would like to pass data to and then initialized it within the constructor of the user control:
private Uc_inputtingPaymentDetails _InputtingPaymentDetails;
public Uc_bookingDetails()
{
InitializeComponent();
creationOfSqlDataFunctions();
_InputtingPaymentDetails = new Uc_inputtingPaymentDetails();
}
I have then created a public string inside of the user control where i would like to store my data:
public string CoachId { get; set; }
when clicking a confirm button, I have called this string as shown below, to store the value of the text box inside of the CoachID string, however after placing breakpoints at this line it says that the CoachId is null. Does anyone know why this is?
private void confirmBookingBtn_Click_1(object sender, EventArgs e)
{
_InputtingPaymentDetails.CoachId = txtCoachId.Text; // **this is where im trying to store the txtCoachId.Text value inside of the CoachId string variable.**
string query_1 = "UPDATE Coach set numberOfSeats = numberOfSeats-1 WHERE Coach.CoachId = ' "+int.Parse(txtCoachId.Text)+" ' ";
string query = "Insert into Bookings (departingFrom, destination, dateOfJourney, seatNo, ticketType, price, scheduleId, customerId ) VALUES (' " + txtDeparting.Text + " ',' " + txtDestination.Text + " ',' " + txtDepartureDate.Text + " ',' " + selectedSeatNo + " ',' " + txtTicketType.Text + " ',' " + txtPrice.Text + " ',' " + txtSchedule.Text + " ',' " + SignIn.userDetails[0] + " ' )";
if (selectedSeatNo == null)
{
MessageBox.Show("Please ensure you have reserved a seat for your journey");
}
else
{
_IsqlDataFunctions.ManagingData(query);
_IsqlDataFunctions.ManagingData(query_1);
ShowUserControl(new User_Control.Uc_inputtingPaymentDetails());
}
}
By the way, I know I shouldn't be using concatenated strings for sql queries. I will be changing this soon.
Based on my test, I find that I can pass the variable CoachId successfully.
Therefore, you can check if the following code is working for you.
BookUserControl:(Add a button and a textbox)
public partial class BookUserControl : UserControl
{
private PaymentUserControl pay;
public BookUserControl()
{
InitializeComponent();
pay = new PaymentUserControl();
}
private void button1_Click(object sender, EventArgs e)
{
pay.CoachId = textBox1.Text;
MessageBox.Show(pay.CoachId);
}
}
PaymentUserControl:
public partial class PaymentUserControl : UserControl
{
public PaymentUserControl()
{
InitializeComponent();
}
public string CoachId { get; set; }
}
I add the BookUserControl to the form1, and I can get a messagebox about CoachId when I click the button.
As i'm trying to web scrape a part from the website. Here is an image below.
as the pagination is checked in red box i need to extract value of last in the image above it is 151. So the pagination is dynamic which is hard to extract when i check using view page source in only <div class="jsx-46358917 pagination-wrapper text-center"></div> is shown as inside its value is missing as i understand it is dynamic but i need the last value from the pagination example 151.
Here is a code which i have done so far to web scrape it.
public void parseItem(HtmlDocument doc, string zipCode)
{
//Getting json data
if (doc.DocumentNode.LastChild.HasChildNodes)
{
var siteScripts = doc.DocumentNode.SelectSingleNode("//script[#id='__NEXT_DATA__']").InnerText;
var result = JsonConvert.DeserializeObject<RealtorModel>(siteScripts);
if (result != null)
{
foreach (var realtor in result.Props.CriteriaData.SrpShell.LoadedData.SearchResults.HomeSearch.Results)
{
string propertyId = "M" + realtor.PropertyId;
string address = realtor.Location.Address.Line + ", " + realtor.Location.Address.City + ", " + realtor.Location.Address.StateCode + " " + realtor.Location.Address.PostalCode;
string listingURL = hostName + "/realestateandhomes-detail/" + realtor.Permalink;
var url = realtor.PrimaryPhoto;
listings.Add(new Listings { PropertyID = propertyId, Address = address, Price = realtor.ListPrice, ImageURL = realtor.PrimaryPhoto.Href.AbsoluteUri, ListingURL = listingURL });
}
}
pageNumber = pageNumber + 1;
string nextUrl = "https://www.realtor.com/realestateandhomes-search/" + zipCode + "/type-single-family-home" + "/pg-" + pageNumber;
AddTask(nextUrl, this.parseItem, zipCode);
}
else
{
System.Threading.Thread.Sleep(60000);
string nextUrl = "https://www.realtor.com/realestateandhomes-search/" + zipCode + "/type-single-family-home" + "/pg-" + pageNumber;
AddTask(nextUrl, this.parseItem, zipCode);
}
}
As i get the complete page through scraping only thing is the last value of the paginate which i cannot extract due to its dynamic nature. How can i achieve to do so any hint would be helpful.
I have a page there is a button that generates a Link like this.
private string GenerateLINK(string NameID)
{
string NameID= ds.Tables[0].Rows[0]["FName"] + " " + ds.Tables[0].Rows[0]["LName"];
string sQS = ID+ "|" + ClientName;
var xCrypto = new CryptoServer();
string Vector= null;
string sEncrypted = null;
xCrypto.Encrypt3DES(sQS, ref sEncrypted, ref Vector);
string sURL = sEncrypted + "#######" + Vector;
sURL = Server.UrlEncode(sURL);
sURL = "https://www.Page.aspx?s=" + sURL;
return sURL;
}
This then gets sent to a user who clicks on it and goes to a page.
Now the issue is I take the link like this and DCode it.
private void DecryptQuerystring()
{
var sQS = Request.QueryString["s"];
sQS = Server.UrlDecode(sQS);
var idelim = sQS.IndexOf("###X####", StringComparison.Ordinal);
var sIv = sQS.Substring(idelim + 8);
sQS = sQS.Substring(0, idelim);
var xCrypto = new ICECrypto.CryptoServer();
sQS = xCrypto.Decrypt3DES(sQS, sIv);
string sID = sQS.Substring(0, sQS.IndexOf("|"));
studentID = sID;
Name = sQS.Substring(sQS.IndexOf("|") + 1);
Welcome.InnerText = "Welcome " + sQS.Substring(sQS.IndexOf("|") + 1);
}
The Problem is when the User gets there and if he puts in any word in the link it breaks the whole page showing the Server Error. I want user to NOT to be able to Edit the Link insert any thing in it. Any clue? Thanks in advance!
This is funny but I am answering my own question maybe someone else could use it.
So where I am doing the Decryption of the QueryString() i put in the word
Try {
// Do the Decryption here
}
Catch(Exception ex) {
// if any thing goes wrong in that Try it will hit here and then i will show error 404
}
I've been encountering a problem when I click on the button that should redirect to paypal it opens my documents. It was running before but when I transferred the codes to another PC the error occurs. Help!
Here is the code in aspx.cs
protected void btnPayOnline_Click(object sender, EventArgs e)
{
string url = "";
string business = "business#yahoo.com";
string description = "Buy";
string country = "PH";
string currency = "PHP";
string amount = Label1.Text;
url += "https://www.sandbox.paypal.com/cgi-bin/webscr" +
"?cmd=" + "_xclick" +
"&business=" + business +
"&amount=" + amount +
"&lc=" + country +
"&item_name=" + description +
"¤cy_code=" + currency +
"&bn=" + "PP%2dBuyNowBF";
System.Diagnostics.Process.Start("explorer.exe", url);
}
Here is the aspx codes:
I really dont see what the problem is
Your program starts the folder explorer (thus showing your default local directory), not your web browser.
Replacing explorer.exe by iexplore.exe should solve your issue.
I have a method that runs through a loop that can take quite a while to complete as it requires getting data back form an API.
What I would like to do is display a message on the front end explaining how the system is progressing during each loop. Is there a way to update the front end while processing?
public static void GetScreenshot(List<string> urlList, List<DesiredCapabilities> capabilities, String platform, Literal updateNote)
{
foreach (String url in urlList)
{
String siteName = new Uri(url).Host;
String dir = AppDomain.CurrentDomain.BaseDirectory+ "/Screenshots/" + siteName + "/" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm");
foreach (DesiredCapabilities cap in capabilities)
{
String saveDirectory = "";
if (platform == "btnGenDesktopScreens")
{
saveDirectory = dir + "/" + cap.GetCapability("os") + "-" + cap.GetCapability("os_version") + "-" + cap.GetCapability("browser") + cap.GetCapability("browser_version");
}
else if(platform == "btnMobile")
{
saveDirectory = dir + "/" + cap.GetCapability("platform") + "" + cap.GetCapability("device") + "-" + cap.GetCapability("browserName");
}
updateNote.Text += "<br/>" + cap.GetCapability("platform") + " - " + cap.GetCapability("device") + "-" + cap.GetCapability("browserName");
//I'd like to display a message here
TakeScreenshot(url, cap, saveDirectory);
//I'd like to display a message here
}
}
}
Has anyone come across a method of doing this?
Depending on how you're returning the feedback to the user, you might be able to do this by using HttpResponse.Flush in a loop to push parts of the HTML response to the user a bit at a time. See https://msdn.microsoft.com/en-us/library/system.web.httpresponse.flush(v=vs.100).aspx