Open jquery ui dialog from itemcommand - vb.net

I'd like to be able to display iframe content in Jquery UI dialog and not a pop up as I'm currently doing, but I can't seem to find a way of getting this accomplished.
My current solution looks like this:
If e.CommandName = "CustIDCommand" Then
Dim CustIDButton As LinkButton
CustIDButton = FindControl("CustIDBtn")
Dim str As String = "<script language='Javascript'>"
str = str + "window.open('/secure/CustCC.aspx','newwin','location=no,toolbar=no,menubar=no,width=500,height=275,left=400,top=300')"
str = str + "</script>"
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "win", str)
Session("CustID") = e.CommandArgument
End If
An ID number is passed so the CustCC.aspx page displays the correct data. All works fine, but I'd like to load this page in a modal and not a pop up.
Any help greatly appreciated

Do something like this:
$("#somediv").load(url).dialog({modal:true});
https://jqueryui.com/dialog/

Related

How do you reference data from different formview (ASP.NET)

I'm a still new to the whole creating a website please understand and explain in simple terms.
Ok, so there's a formview called FormView1 and another formview called User. In FormView1 I have a data called CoinEarn and the other formview data called CurrentCoin (from different formview)
I want to update CurrentCoin through a session so I could put it on my update SQL (by Session("CurrentCoin") = CurrentCoin + CoinEarn) after clicking a button (which is placed inside FormView1 template). In the code I gave the button the command name "complete".
Since CurrentCoin is from a different SQL and formview I need to reference/call up the specific data (CurrentCoin) so I can make the session.
I'm not sure if my thought/solution on this problem is correct or not (by calling up data or make a session to update CurrentCoin) but the main objective is to make CurrentCoin += CoinEarn after clicking a button.
Please help me! I've been trying to find the answer but it's too complicated to understand in proper websites.
Protected Sub FormView1_ItemCommand(sender As Object, e As FormViewCommandEventArgs) Handles FormView1.ItemCommand
If e.CommandName = "complete" Then
Dim row As FormViewRow = FormView1.Row
Dim TaskstatusLabel As Label = CType(row.FindControl("TaskStatusLabel"), Label)
Dim what As String = TaskstatusLabel.Text
Dim TaskCoin As Label = CType(row.FindControl("CoinEarnLabel"), Label)
Dim Coin As String = TaskCoin.Text
''Session("CurrentcoinSession") = Coin + CurrentCoin
Dim TaskstatusLabelID As Label = CType(row.FindControl("TaskIDLabel"), Label)
Dim whatTaskID As String = TaskstatusLabelID.Text
Session("TaskIDSession") = whatTaskID
If TaskstatusLabel.Text = "Complete" Then
Session("TaskStatusSession") = "Incomplete"
ElseIf TaskstatusLabel.Text = "Incomplete" Then
Session("TaskStatusSession") = "Complete"
End If
SqlDsStatus1.Update()
FormView1.DataBind()
End If
End Sub
Use of session CurrentCoin optional:
Session("CurrentCoin") = ((Label)MyFormView.FindControl("lblCurrentCoin")).Text
Session("CurrentcoinSession") = Coin + Session("CurrentCoin")
get values from a form view

GetElementById Two same ID's

Hey I need help well im trying to make a program that uses a site to do some stuff and it has two of the same id's for both textboxs im trying to input into my code is WebBrowser2.Document.GetElementById("form-control-3").InnerText = BunifuMaterialTextbox1.Text. Well anyway im tryint to do that to input into the first textbox and the 2nd textbox has the same id and classname so i don't really know what to do.
You could try grabbing all the HTML elements based on the tag and then loop through to see if the id matched. Something like...
Dim Elems As HtmlElementCollection
Elems = WebBrowser2.Document.GetElementsByTagName("[tagName]")
For Each elem as HtmlElement in Elems
Dim idStr As String = elem.GetAttribute("id")
If ((idStr IsNot Nothing) And (idStr = "form-control-3"))
elem.InnerText = BunifuMaterialTextbox1.Text
End If
Next
i don't know if this help but you can do a input array
example:
<input name="name[]">
and...
document.getElementsByName("name[]")

How do I search through a string for a particular hyperlink in Visualbasic.net?

I have a written a program which downloads a webpage's source but now I want to search the source for a particular link I know the link is written like this:
<b>Geographical Survey Work</b>
Is there anyway of using "Geographical Survey Work" as criteria to retrieve the link? The code I am using to download the source to a string is this:
Dim sourcecode As String = ((New Net.WebClient).DownloadString("http://examplesite.com"))
So just to clarify I want to type into an input box "Geographical Survey Work" for instance and "/internet/A2" to popup in a messagebox? I think it can be done using a regex, but that's a bit beyond me. Any help would be great.
With HTMLAgilityPack:
Dim vsPageHTML As String = "<html>... your webpage HTML code ...</html>"
Dim voHTMLDoc.LoadHtml(vsPageHTML) : vsPageHTML = ""
Dim vsURI As String = ""
Dim voNodes As HtmlAgilityPack.HtmlNodeCollection = voHTMLDoc.SelectNodes("//a[#href]")
If Not IsNothing(voNodes) Then
For Each voNode As HtmlAgilityPack.HtmlNode In voNodes
If voNode.innerHTML.toLower() = "<b>geographical survey work</b>" Then
vsURI = voNode.GetAttributeValue("href", "")
Exit For
End If
Next
End If
voNodes = Nothing : voHTMLDoc = Nothing
Do whatever you want with vsURI.
You might need to tweak the code a bit as I'm writing free-hand.

Put text into a textbox from a website in VB.NET

I want to know how to put text to a website's textbox with VB.NET.
Like when you complete a textbox and press enter.
Something like this:
Dim web as webbrowser
web.document.textbox(1).insert("text")
it would look something like this:
WebBrowser1.Document.GetElementById("login_password").SetAttribute("value", TextBox2.Text)
As giuseppe has suggested, you need to search for the element in the document and then set it's value property. for example following code logins into website by setting its userId and password textboxes and clicking the submit button.
Dim htmlDoc=WebBrowser1.Document
Dim elem_Input_UsrName As HtmlElement = htmlDoc.GetElementById("username")
Dim elem_Input_PssWrd As HtmlElement = htmlDoc.GetElementById("password")
Dim elem_Input_Submit As HtmlElement = getElementByClassName("Submit", "Input", htmlDoc)
If elem_Input_UsrName IsNot Nothing AndAlso elem_Input_PssWrd IsNot Nothing Then
elem_Input_UsrName.SetAttribute("value", "xyz#ABC.com")
elem_Input_PssWrd.SetAttribute("value", "yourpassoword")
elem_Input_Submit.InvokeMember("click")
End If
This will help 100%:
webbrowser1.document.getElementById("yourtextboxidinwebsite").innertext = textbox1.text
I get a way that if u want to receive from the website itself another way I need to receive results from the website into the text box. U can use this method.
first, make a web browser to load the page
WebBrowser1.Navigate("https://tools.keycdn.com/geo")
then this
TextBox1.Text = WebBrowser1.Document.GetElementById("geoResult").InnerText

Text from webpage

I need to get some text from this web page. I want to use the trade feed for my program to analyse the sentiment of the markets.
I used the browser control and the get element command but its not working. The problem is that whenever my browser starts to open the page I get Java scripts errors.
I tried with DOM but seems that i dont quite understand what i need to do :)
Here is the code:
Dim code As String
Using client As New WebClient
code = client.DownloadString("http://openbook.etoro.com/ahanit/#/profile/Trades/")
End Using
Dim htmlDocument As IHTMLDocument2 = New HTMLDocument(code)
htmlDocument.write(htmlDocument)
Dim allElements As IHTMLElementCollection = htmlDocument.body.all
Dim allid As IHTMLElementCollection = allElements.tags("id")
Dim element As IHTMLElement
For Each element In allid
element.title = element.innerText
MsgBox(element.innerText)
Next
Update: So I tried the HTML Agility pack, as suggested in the comments, and I am stuck again on this code
Dim plain As String = String.Empty
Dim htmldoc As New HtmlAgilityPack.HtmlDocument
htmldoc.LoadHtml("http://openbook.etoro.com/ahanit/#/profile/Trades/")
Dim goodnods As HtmlAgilityPack.HtmlNodeCollection = htmldoc.DocumentNode.SelectNodes("THE PROBLEM")
For Each node In goodnods
TextBox1.Text = htmldoc.DocumentNode.InnerText
Next
Any advice what to now?
Ok I think I know what the problem is somehow the div that I need is hidden and its not loaded when I load the web page just the source code. Does someone knows how to load all the hidden divs ??
Here is my new code
Dim doc As New HtmlAgilityPack.HtmlDocument
Dim web As New HtmlWeb
doc = web.Load("http://openbook.etoro.com/ahanit/#/profile/Trades/")
Dim nodes As HtmlNode = doc.GetElementbyId("feed-items")
Dim id As String = nodes.WriteTo()
TextBox1.Text = TextBox1.Text & vbCrLf & id
user1336635,
Welcome to SO! Something you might try is to check out his source code, figure out what javascript function is populating the field you want (using firebug - I assume it's the one that "trades result in profit" next to it), and then embedding that script into a web page that your webbrowser control loads. That's where I'd try to start. I checked his source code and searched for "trades result in profit" and didn't find anything which leads me to believe hunting for the element 'might' not be possible. Just a starting place until someone with more experience with this chimes in!! Best!
-sf