how i can send data to html cefsharp vb.net - cefsharp

This is the source code for the webpage I'm working on.
And This is my code to send the data from the textbox to the web page browser1.ExecuteScriptAsync("document.querySelector('input[ng-model=NationalId]').value='" + TextBox1.Text + "'") browser1.ExecuteScriptAsync("document.querySelector('input[ng-model=PrincipleCode]').value='" + TextBox2.Text + "'")
it works and sends the data, but when I press the enter button, it does not feel the written data and asks me to enter the data
plz help me

It's not uncommon for web pages to have additional input validation.
I've recently published a CefSharp specific port of puppeteer Sharp which should let you do something like the following:
var page = await chromiumWebBrowser.GetPuppeteerPageAsync();
// Type into input field
await page.TypeAsync(#"input[ng-model=NationalId]", TextBox1.Text);
The package is available at https://www.nuget.org/packages/CefSharp.Puppeteer/
See also https://github.com/cefsharp/Puppeteer/blob/main/samples/searching/Program.cs

Related

Getting the session data from ASP classic isn't working

I am currently tasked with moving one of our older bits of software to a new server. The old server is running 2008 and the new server is on 2019. The code is a mixture of ASP and ASP.NET, both using VB. Unfortunately, I'm a C# developer and my VB knowledge is slight.
The main bit of the code is the older and is all in ASP and works fine on the new server. For a particular set of customers there is an add-on that is more recent and uses ASP.NET. For the new section of code to get the details of the logged in user it uses the code given in this answer. Unfortunately it seems like it is this bit of code that is failing.
We have this bit of code in our site.master.vb
ctx1 = ctx.Request.Url.Scheme
ctx2 = ctx.Request.Url.Host
dom = ctx1 + "://" + ctx2
Dim ASPRequest As HttpWebRequest = WebRequest.Create(New Uri(dom + "/arc/asp2netbridge.asp?sessVar=" + sessionValue))
ASPRequest.ContentType = "text/html"
ASPRequest.Credentials = CredentialCache.DefaultCredentials
If (ASPRequest.CookieContainer Is Nothing) Then
ASPRequest.CookieContainer = New CookieContainer()
End If
The asp2netbridge.asp file is stored in the directory one up from the directory that contains the code and the directory structure looks the same on both servers. The contents of the as2netbridge file are the the same as in the example code linked above with the addition of some extra comments.
It then calls a Stored Procedure on our database with the customer ID from session that should return the customer details as XML, but instead we get a 'Root Element is missing' Error. If I change the Stored Procedure to hard code the customer ID in it, rather than as a parameter then it works as expected.
Is there anything that I need to install on our server to get the system working correctly? Or is there anything else I need to do to get it to work?

Access request after upload (ASP classic)

So, as I figured out, when I have a form with enctype="multipart/form-data" and I upload a file, I can no longer access the object request. The following error is shown:
Cannot use the generic Request collection after calling BinaryRead.
After checking some resources, I stumpled upon a statement, which says: "This is by design". Well, okay, not here to judge about design-decisions.
To give you a quick overview, let me walk you through the code:
if request("todo") = "add" then
Set Form = New ASPForm
category = request("category")
title = request("title")
if len(Form("upload_file").FileName) > 0 then
filename = Form("upload_file").FileName
DestinationPath = Server.mapPath("personal/allrounder/dokumente/")
Form.Files.Save DestinationPath
end if
end if
Nothing too special here so far. Later however, when I try to access my request object, the error mentioned above occures:
<% if request("todo") = "new" then %>
...
My question now, how to get rid of it or fix this. I don't want to open the upload in a popup if there is another way around. This is the only solution I could think off.
Perfectly would be an object, which checks Form and request. Alternatively maybe a check at the top of the file, which object I have to use?
Thanks for any suggestions.
There used to be a very popular ASP class/component that solved ASP file uploads. The site for that component has been taken down, but the code is mirrored here:
https://github.com/romuloalves/free-asp-upload
You can include this ASP page on your own page, and on your page instantiate the class to get access to the files in your form, but also to the form variables. Here is a piece of example code (Upload.Form accesses the form fields):
Dim uploadsDir : uploadsDir = server.mapPath(".") ' whatever you want
Dim Upload, ks, fileKey, mailto
Set Upload = New FreeASPUpload
call Upload.Save(uploadsDir)
ks = Upload.UploadedFiles.keys
for each fileKey in ks
Response.write(fileKey & " : " & Upload.UploadedFiles(fileKey).FileName & "<br/>")
next
mailto = Upload.form("mailTo")
Set Upload = Nothing
If you want to stick to your own implementation, you can probably figure out how to get to the form variables in a multipart/form-data encoded data stream by having a look at the code they use to do so.

MsgBox doesn't work after deployment

I've deployed my ASP.NET application today. It's a web application (I am using forms, etc.). I was happy with all my functionalities. For example, I had part of the of the code that says
if c.results = " " then MsgBox("Error! No record was returned)
Then I clear all my text boxes.
That MsgBox was working when I was running my application locally, but now that I've deployed it I get a server run error! I read some similar posts that said MsgBox is not supported with web applications, but all their answers were with JavaScript. I am not familiar with it, but I don't understand how to put my JavaScript in my Visual Basic class instead of where I am calling the MsgBox- is there a way fixing the above issue with VB.NET code?
Here is the code:
Dim results = customer.getCustomerDetails(txtCustomerNumber.Text, txtDOB.Text)
If (results.customerNumber = "") Then
Response.Write("<script>alert('Customer record not found')</script>")
txtCustomerNumber.Text = ""
txtDOB.Text = ""
Else
( Do the other stuff)
End if
MsgBox is server side so it can't show up to the client which is only seeing the client side of the ASP.NET webform, hence use the following if you want to access a JavaScript alert from code behind or simply alert in JavaScript:
Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "<script
language=JavaScript>alert('your wanted message');</script>")
You can generate client code from your server side VB as such:
If c.results = " " Then
Response.Write("<script>alert('Error! No record was returned')</script>")
End If

Paypal Sandbox Return Url not working vb.net

I am in the beginning stages of working with paypal checkout in my website and I am trying to use a sandbox account to test some things out. I am able to go through and purchase the item with another sandbox account but after I purchase the item, it stays on the paypal checkout page and tells me that I have completed my payment and I will receive an email notification. I need it to return to some other website url so that I can try to get details of the transaction in my code behind. My code posted below is very basic and I do not have anything in the code itself about the return URL, I have filled it in under my sandbox account settings.
The second part of the problem is that I have not published my website yet, I am using the visual basic debugger to view and test my site in a browser and when I attempt to put my "local host" url into the return url it gives an error: "We were unable to validate the URL you have entered. Please check your entry and try again." an example of the url I am trying to put in is
http://localhost:11111/WebSite1/Parts_Catalog.aspx
As a test url just to attempt to start getting data back from the transaction I just put in google.com thinking that it would at least return to google with either an error or the returned query strings but it doesn't attempt to load any pages at all after the transaction.
How can I get the paypal sandbox return url to actually return to a URL? How can I enter my local host URL into the website preferences return url and actually get it to recognize my url as listed above?
Here is the markup code
<asp:ImageButton ID="AddToCartBtn" runat="server"
RowIndex='<%# Container.DisplayIndex %>'
ImageUrl="~/Pictures/ShoppingCart.png"
OnClick="AddToCartBtn_Click" />
Here is the code I have so far for my addToCart button, I don't know if I need to add anything here or not for the return url
Protected Sub AddToCartBtn_Click(sender As Object, e As ImageClickEventArgs)
Dim Item As String = "Test"
Dim price As String = cost
Dim business As String = "test#aol.com"
Dim itemNumber As String = str2
Dim itemAmount As String = price
Dim currencyCode As String = "USD"
Dim addItem As Integer = 1
Dim ppHref As StringBuilder = New StringBuilder()
ppHref.Append("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart")
ppHref.Append("&business=" + business)
ppHref.Append("&item_name=" + itemName)
ppHref.Append("&item_number=" + itemNumber)
ppHref.Append("&amount=" + itemAmount)
ppHref.Append("&currency_code=" + currencyCode)
ppHref.Append("&add=" + addItem.ToString("#0"))
Response.Redirect(ppHref.ToString(), True)
Dim ReturnQaunity As String = itemAmount
GetRouteUrl("/v1/payments/orders/<Order-Id>")
End Sub
I don't currently have anything in my page load event that deals with paypal.
Andre is right, the return URL must be accessible to PayPal.
What you can do is use a generic URL (I guess google.com would work but it might be better to use one of your own) then edit the URL in the browser window.
So return to something like http://www.test.com/return.html?paypalparms...
Then when it displays in your browser change the URL to
http://localhost/return.html?paypalparms...
Then press enter.
I have used a similar technique with PayPal PDT and IPN testing and it works fine.
I would have replied to your comment but I haven't yet reached the dizzy heights of 50 reputation which allows me to comment everywhere.

get a website data and display on my web page

I am Trying to display a website portion on my web page.and for this i dnt want to use iframe.But any other idea which can get data from a website and then display it on my web page like.
this is website
http://www.sugaronline.com/
and want to display this portion on m y web page
http://i.stack.imgur.com/CVsrh.jpg
Please any one tell me is there any way to do this except using iframe?
Update
Shared Function GetHtmlPage(ByVal strURL As String) As String
Dim strResult As String
Dim objResponse As WebResponse
Dim objRequest As WebRequest = HttpWebRequest.Create(strURL)
objResponse = objRequest.GetResponse()
Using sr As New StreamReader(objResponse.GetResponseStream())
strResult = sr.ReadToEnd()
sr.Close()
End Using
Return strResult
End Function
Dim responses As String = GetHtmlPage(theurl)
Refer existing posts
Using HTTPWebRequest in ASP.NET VB
or simply Google this
If you are using PHP, try using CURL, it is a server side request which fetches the data from the target site and then you can embed it in your page.
On the other hand, if you are using .Net, you can use httpwebrequest to do the same.
In short, you will have to make a server side request from your server to the target website to fetch the data and you can embed that data on your page as if it has come from your website.
Please check out this post
How to use httpwebrequest to pull image from website to local file
Here all you need to do is
when you have the image bytes ready, you need to write those bytes to response but before that, you will have to send proper headers to let the browser understand that you are now going to send the image.

Resources