<div id="ctl00_cphRoblox_rbxGroupFundsPane_GroupFunds" class="StandardBox" style="padding-right:0">
<b>Funds:</b>
<span class="robux" style="margin-left:5px">128</span>
</div>
Ok so I want to get the 128 but sometimes it gives me "18"
and I have no idea
I tried:
dcWeb.SendMessage(s + " = Pending and Robux: " + driver.FindElement(By.ClassName("robux")).GetAttribute("innerHTML"));
and
dcWeb.SendMessage(s + " = Pending and Robux: " + driver.FindElement(By.ClassName("robux")).GetAttribute("textContent"));
To to get the text 128 you can use the following line of code :
dcWeb.SendMessage(s + " = Pending and Robux: " + driver.FindElement(By.XPath("//div[#class='StandardBox' and contains(#id,'_cphRoblox_rbxGroupFundsPane_GroupFunds')]//span[#class='robux']")).GetAttribute("innerHTML"));
Related
I am calling jQuery Modal Pop up with some dynamic information, How I can set width of modal popup div from my c# Code.
Here is my current call from c#
string jqmsg = " Dear Applicant,</br> <p>Your enquiry registered, The Email verification link has been sent to you registred Email ID " + txtEmail.Text + " and your registration reference ID is <Strong> " + Session["REGID"].ToString() + " </Strong></p>";
ClientScript.RegisterStartupScript(this.GetType(),"Popup", "ShowPopup('" + jqmsg + "');", true);
Thanks in advance.
I thought I would answer the comment I made above with an answer so I could more easily show code. This is what I mean:
c#
var width = 400;
string jqmsg = " Dear Applicant,</br> <p>Your enquiry registered, The Email verification link has been sent to you registred Email ID " + txtEmail.Text + " and your registration reference ID is <Strong> " + Session["REGID"].ToString() + " </Strong></p>";
ClientScript.RegisterStartupScript(this.GetType(),"Popup", "ShowPopup('" + jqmsg + "', " + width + ");", true);
javascript
function ShowPopup(message, width) {
// other ShowPopupCode
document.getElementById("modalDivId").style.width = width + 'px';
}
Would that work for you?
It's print double, I can't see any error of my code, I use match collection in regular expression, if match collection found 2 (youtube link). the function print 4 images. by the way the function get the youtube thumnails.
Plaintext:
string Plainttext = "This selection is automatically generated based on videos that were popular <br/>" +
" in the past few weeks. <br/>" +
" ------------------------------------------------------------------- \n" +
" 'Anniversary Prank Backfires!! \n" +
" http://www.youtube.com/watch?v=R7AXBOT8KzU&feature=em-hot \n" +
" by RomanAtwood " +
" 23,268,129 views " +
" ------------------------------------------------------------------- \n" +
" We Are The World for Philippines [TYPHOON HAIYAN] \n" +
" http://www.youtube.com/watch?v=1bI8pGLBagY&feature=em-hot \n" +
" by Kevin Ayson " +
" 3,607,584 views <br/>" +
" ------------------------------------------------------------------- <br/>" +
" end of text ";
Button:
protected void Button1_Click(object sender, EventArgs e)
{
Literal1.Text = GetYoutubeThumbnails(Plainttext);
}
Function:
string geturl;// static string id ;
protected string GetYoutubeThumbnails(string plaintext)
{
var youtuberegex = new Regex("youtu(?:\\.be|be\\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
StringBuilder sb = new StringBuilder();
MatchCollection matches = youtuberegex.Matches(plaintext);
ArrayList arrayURL = new ArrayList(matches);
// foreach (Match match in matches)
for (int i = 0; i <= arrayURL.Count-1 ; i++ )
{
geturl = arrayURL[i].ToString();
string id = string.Empty;
Match youtubeMatch = youtuberegex.Match(geturl);
id = youtubeMatch.Groups[1].Value;
// if(match.Success)
// {
sb.Append(string.Format(#"<table runat ='server'><tr> <td id = 'tduserPicture'
rowspan='1' style='text-align:left' runat='server'>
<img ID='Imagess2' runat='server' src='{0}' Height='80px' Width='100px' /alt='image'>
<br/> {1} </td> </tr></table>", "http://img.youtube.com/vi/" + id + "/0.jpg", "www." + geturl));
// }
}
plaintext = youtuberegex.Replace(plaintext, sb.ToString());
return plaintext;
}
Output:
Thanks
The problem is your modifying the text inside your loop, a separate output should be created rather than an in-place replace.
Don't even bother doing it like that, use a Regex.Replace callback function.
Knocked this together as a super quick sample
using System.IO;
using System;
using System.Collections;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string Plainttext = "This selection is automatically generated based on videos that were popular <br/>" +
" in the past few weeks. <br/>" +
" ------------------------------------------------------------------- \n" +
" 'Anniversary Prank Backfires!! \n" +
" http://www.youtube.com/watch?v=R7AXBOT8KzU&feature=em-hot \n" +
" by RomanAtwood " +
" 23,268,129 views " +
" ------------------------------------------------------------------- \n" +
" We Are The World for Philippines [TYPHOON HAIYAN] \n" +
" http://www.youtube.com/watch?v=1bI8pGLBagY&feature=em-hot \n" +
" by Kevin Ayson " +
" 3,607,584 views <br/>" +
" ------------------------------------------------------------------- <br/>" +
" end of text ";
MatchEvaluator evaluator = new MatchEvaluator(MatchFilter);
Console.WriteLine(Regex.Replace(Plainttext,
"youtu(?:\\.be|be\\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)", evaluator,
RegexOptions.IgnorePatternWhitespace));
}
static string MatchFilter(Match match) {
var id = match.Groups[1].Value;
var geturl = match.ToString();
return string.Format(#"<table runat ='server'><tr> <td id = 'tduserPicture'
rowspan='1' style='text-align:left' runat='server'>
<img ID='Imagess2' runat='server' src='{0}' Height='80px' Width='100px' /alt='image'>
<br/> {1} </td> </tr></table>", "http://img.youtube.com/vi/" + id + "/0.jpg", "www." + geturl);
}
}
This outputs the following:
This selection is automatically generated based on videos that were popular <br/> in the past few weeks. <br/> -------------------------------------------------------------------
'Anniversary Prank Backfires!!
http://www.<table runat ='server'><tr> <td id = 'tduserPicture'
rowspan='1' style='text-align:left' runat='server'>
<img ID='Imagess2' runat='server' src='http://img.youtube.com/vi/R7AXBOT8KzU/0.jpg' Height='80px' Width='100px' /alt='image'>
<br/> www.youtube.com/watch?v=R7AXBOT8KzU </td> </tr></table>&feature=em-hot
by RomanAtwood 23,268,129 views -------------------------------------------------------------------
We Are The World for Philippines [TYPHOON HAIYAN]
http://www.<table runat ='server'><tr> <td id = 'tduserPicture'
rowspan='1' style='text-align:left' runat='server'>
<img ID='Imagess2' runat='server' src='http://img.youtube.com/vi/1bI8pGLBagY/0.jpg' Height='80px' Width='100px' /alt='image'>
<br/> www.youtube.com/watch?v=1bI8pGLBagY </td> </tr></table>&feature=em-hot
by Kevin Ayson 3,607,584 views <br/> ------------------------------------------------------------------- <br/> end of text
i currently have a textbox field, everytime a change is made, i add who it was updated by and what time
right now it keep appending that text
how can i find the line that says "LastEdited: ", and only replace the time stamp value?
this is what i do now
maybe someone can post me example of code how to grab the timestamp and replace it?
if (txtMemberNotesOriginally != txtMemberNotesChanged) {
txtMemberNotes.AppendText("LastEdited: " + DateTime.Now.ToString() + " By: " + MyProgramName.Username + Environment.NewLine);
i am not an expert, so an example of code would bevery useful
i do use this textbox to save other notes as well (which i wouldn't wanna loose)
can i do this
foreach (var line in txtMemberNotes.Lines) {
if (line.StartsWith("Last Edited: "))
{
txtMemberNotes.Text = txtMemberNotes.Text.Replace(line, "Last Edited: " + DateTime.Now.ToString() + " By: " + MyProgramName.Username + Environment.NewLine);
}
else
{
txtMemberNotes.AppendText("Last Edited: " + DateTime.Now.ToString() + " By: " + MyProgramName.Username + Environment.NewLine);
}
}
The easiest way to solve your problem seems to stop appending text and just set the text value. No parsing is necessary, just overwrite the exiting values with your newer value.
if (txtMemberNotesOriginally != txtMemberNotesChanged) {
txtMemberNotes.Text = "LastEdited: " + DateTime.Now.ToString() + " By: " + MyProgramName.Username + Environment.NewLine;
I guess theres always Regex if you really wanted:
string s = #"Some notes here etc etc..
Last edited: 12/12/2012 12:00:00 AM";
Console.Write(Regex.Replace(s, #"Last edited: .*$", "Lasted edited: " + DateTime.Now.ToString()));
Or more specifically using your code:
txtMemberNotes.Text = Regex.Replace(txtMemberNotes.Text, #"Last edited: .*$", "Lasted edited: " + DateTime.Now.ToString());
I'm new here, I'm stuck in problem in which i have to loop my button so that i will be able to put it on my looping div. How will I do that? This is what I got so far:
//my loop
for (i = 0; i < MPreply.recommendation.Length; i++) {
html += "<div class='rec'> ";
html += "</br> <div id = 'from1' value = > Depart From:" + " ";
html += emz + " " + "(" + + ")" + "</div>";
html += "<div id = 'date1' > Schedule:" + " " + flytDate;
html += " , " + convertedString;
html += "</div>" + "<div id = 'to1' >To:" + " " + emz2 + " " + "(" + "" + ")";
html += "</div> </br> </br> </br> ";
html += "<div id = 'RecNo'>" + " " + (i + 1) + " )" + " </br> </br> </div> ";
html += "<div id = 'fare1'> $" + em + " </div> ";
html += " </div> <br/> <br/>";
div_rec.InnerHtml = html;
}
html:
<div id = 'modal' runat="server" >
<div id="dialog" runat="server">
</div>
<input id="_menuitem" type="button" value="Click" runat="server" />
</div>
Thanks in advance.
You have at least a few problems:
"<div id = 'fare1'>
and similar sections will generate multiple elements with the same id.
div_rec.InnerHtml = html;
Should be moved outside of your loop so that div_rec is only updated once, when everything is done.
emz + " " + "(" + + ")" + "</div>";
Should (probably) be changed to
emz + " " + "(" + your_variable_here + ")" + "</div>";
In order to (I think) add the creation of a button in your loop, you'll have to piece it together as a string just like your other elements. To get a function handler wired up you'll have to either:
a) Build a dom level-0 handler as a string, or
b) Wait until your html is updated, then query out the newly added buttons and add event handlers in code (using either btn.onclick = function(... or dom level-2 handlers (addEventListener or attachEvent)
The Problem i see here is with the ID field.
You have mentioned same ID name for all the Div's you are generating.
Like,
<div id = 'from1'>
<div id = 'to1'>
ID is a unique identifier to an element. It must always be unique.
You can Use Class instead.
Like,
<div class = 'from1'>
<div class = 'to1'>
i am trying to get the values of my controls like this:
function ConfirmWithUser()
{
var nodeText = '';
$('.mytreeview input[#type=checkbox]:checked').each(function() {
nodeText += $(this).next('a').text() + '\r';
});
var confirmationMessage;
confirmationMessage = "Please review the data before submitting:" + "\r"
+ "Sample Received Date: " + document.getElementById(received_dateTextbox).Value + "\r"
+ "Site of Ocurrence: " + document.getElementById(site_of_occurrenceTextBox).Value + "\r"
+ "Occurrence Date: " + document.getElementById(occurrence_dateTextBox).Value + "\r"
+ "Report Date: " + document.getElementById(report_byTextBox).Value + "\r"
+ "Specimen ID: " + document.getElementById(spec_idTextBox).Value + "\r"
+ "Batch ID: " + document.getElementById(batch_idTextBox).Value + "\r\n"
+ "Report Initiated By: " + document.getElementById(report_byTextBox).Value + "\r\n"
+ "Problem Identified By: " + $("input[#name=RadioButtonList1]:checked").val() + "\r\n"
+ "Problem List: " + nodeText;
HiddenFieldConfirmation.Value = confirmationMessage;
if (confirm(document.getElementById('HiddenFieldConfirmation').value) == true)
{ return true; }
else
{ return false; }
}
and the CONFIRM box is not firing at all! i do not get any pop up.
i tried to debug using firefox, and as soon as it go to this line:
confirmationMessage = "Please review the data before submitting:" + "\r"
+ "Sample Received Date: " + document.getElementById(re.......
it escapes out of the function
what am i doing wrong? how can i get the values of all the controls?
You need to use a lowercase "v" for value and quote your element ids. Eg:
document.getElementById("received_dateTextbox").value
Since it appears you are already using jQuery, you can make your code a little more concise. So document.getElementById("received_dateTextbox").value becomes:
$("#received_dateTextbox").val()
There is no variable named spec_idTextBox.
You probably want to pass a string literal.
Once you fix that, you need to use .value in lowercase
If you are using dynamic client ids, you have to render the ids inline or pass them to your function:
confirmationMessage = "Please review the data before submitting:" + "\r"
+ "Sample Received Date: " + document.getElementById('<% = received_dateTextbox.ClientID %>').value + "\r"
+ "Site of Ocurrence: " + document.getElementById('<% = site_of_occurrenceTextBox.ClientID %>').value + "\r"
+ "Occurrence Date: " + document.getElementById('<% = occurrence_dateTextBox.ClientID %>').value + "\r"
+ "Report Date: " + document.getElementById('<% = report_byTextBox.ClientID %>').value + "\r"
+ "Specimen ID: " + document.getElementById('<% = spec_idTextBox.ClientID %>').value + "\r"
+ "Batch ID: " + document.getElementById('<% = batch_idTextBox.ClientID %>').value + "\r\n"
+ "Report Initiated By: " + document.getElementById('<% = report_byTextBox.ClientID %>').value + "\r\n"
+ "Problem Identified By: " + $("input[#name=RadioButtonList1]:checked").val() + "\r\n"
+ "Problem List: " + nodeText;