I'm a newbie wp dev. I want to create a many text file name like 1.text 2.text 3.text ......1760.text and I want user to type the number in text box then click the button and the result is read that typed number.text. how can I do it ? please help
you can try this method:
1. put these txt-files into a path,like:TxtFiles/1.txt,2.txt...
2. when user type the number and click button, execute a method to combine file-path and read the file. and you should check the number first.
StreamResourceInfo resourceInfo = Application.GetResourceStream(new Uri(string.Format("yourFilePath/{0}.txt",userTypedNumber), UriKind.Relative));
using (StreamReader reader = new StreamReader(resourceInfo.Stream))
{
yourContentControl.Text = reader.ReadToEnd();
reader.Close();
}
Related
I opened a new tab from a link in current page. The tab opened but the focus is not shifted to that tab, nor am I able to switch tab using the following two methods I used. I'm using Chrome.
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN);
BaseClass.driver.findElement(By.xpath(xpathOfLinkToPage2)).sendKeys(selectLinkOpeninNewTab);
//method one
ArrayList<String> tabs = new ArrayList<String>(BaseClass.driver.getWindowHandles());
BaseClass.driver.switchTo().window(tabs.get(1));
//method two
String selectLinkOpeninNewTab2 = Keys.chord(Keys.CONTROL,Keys.TAB);
BaseClass.driver.findElement(By.cssSelector("body")).sendKeys(selectLinkOpeninNewTab2);
// open Site 1
String site_1_Window= driver.getWindowHandle();
System.out.println(site_1_Window);
// open Site 2
Set site_Windows= driver.getWindowHandles();
System.out.println(site_Windows);
for (String site_2_Window: driver.getWindowHandles())
{
System.out.println(site_2_Window);
driver.switchTo().window(site_2_Window);
}
try using:
driver.SwitchTo().Window(driver.WindowHandles.Last());
also see this: http://www.binaryclips.com/2016/03/selenium-webdriver-in-c-switch-to-new.html and this Selenium webdriver selecting new window c#
//count and enter your tab index beside get
ArrayList<String> newTab = new ArrayList<String>(driver.getWindowHandles());
driver.switchTo().window(newTab.get(2));
I am using the SSRS 2008r API to create and manage SSRS from a webform application. When creating a folder I see where I can add a folder name as well as specify additional meta data (custom properties) that can be a part of the folder. My question is how do I populate additional fields in the catalog database via the api. When I look at the CreateFolder method the only properties I can add at the insert are folder name, path, and custom properties:
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form
However I would also like to set at this time the description, and hidden value.
I'd appreciate any suggestions on how this is accomplished. Every example I have seen within MSDN only shows setting the folder name, path, and custom properties.
thanks in advance
Set the item properties (Description and Hidden) by initializing a Property class for each. Never done it before, but I'm guessing it would look something like this (assuming C#):
...
// description property
Property description = new Property();
description.Name = "Description";
description.Value = "Your description here.";
// hidden property
Property hidden = new Property();
hidden.Name = "Hidden";
hidden.Value = "True"; // not sure on value here, may be True/False, Yes/No
// build properties array
props[0] = description;
props[1] = hidden;
// create folder
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form
I have used Google captcha code and it works well. The form has no enctype too. I wanted to upload images within the same form element. Then an enctype="multipart/form-data" was added to the form's attribute. I faced the following problems and I use JSP servlets:
1.
String challenge = request.getParameter("recaptcha_challenge_field");
String uresponse = request.getParameter("recaptcha_response_field");
here challenge and uresponse gave null values and therefore
ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remote, challenge, uresponse);
gave null pointer exceptions.
Edit : I found it later that when enctype="multipart/form-datain form tag is used, parameters and its value cannot be retrieved as request.getParameter('') in Servlet.
2. Then I tried to get values for above parameters (challenge and uresponse) through the FileItem as following
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
items = upload.parseRequest(request);
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if (item.isFormField()) {
String name = item.getFieldName();
System.out.println("name: " + name);
String value = item.getString();
System.out.println("value: " + value); // closing scopes ....
These outputs gave no print results for 'recaptcha_challenge_field' and 'recaptcha_response_field'. But other parameters and values of HTML input elements are available. What I observed is, when the form enctype is removed, servlets can have those parameters ('recaptcha_challenge_field' and 'recaptcha_response_field') and its values. When only form enctype is added, parameters not available in servlets.(request.getParameter('recaptha challenge parameter or recaptha-response-field parameter')).
Edit I checked whether the browser sends those parameters(recaptha-challenge ane recaptha-response-field.) with their values and found that browser sends all parameters well. The problem might be in servlet and getting parameters and values inside the FileItem
I want to upload images with this Google captcha code (for human verifications). My current implementation does not work. Does anyone let me know how to implement this?
The reason is in the html itself. When a input type-file is empty(user hasn't not select a file from the local pc),it is difficult or (cannot be done) to retrieve parameter names and their values (in servelt) of those all below html elements' names in my scenario as mentioned in my problem.
I am currently using an Ajax tool; HTMLEditorExtender to turn a textbox into a WYSIWYG editor, in a C# ASP.NET project. On the initial page load I place a large amount of formated text and tables into the editor which appears fine; even the tables.
The data is loaded into an asp:panel and the items/display from the panel is what is actually loaded into the extender and displayed.
However, if I want to have a button that saves all of the data that is in the editor to a Session and after the button press still display everything in the WYSIWG editor on the page postback everything that loads in the the textbox is fine except for the tables. They come up with the tags. Is there anyway around this?
The code I am using to initially load the page is this:
ContentPlaceHolder cphMain = (ContentPlaceHolder)this.Master.FindControl("MainContent");
Panel pnlContent = (Panel)cphMain.FindControl("innerFrame");
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlContent.RenderControl(hw);
txtPN.Text = sb.ToString();
pnlContent.Visible = false;
On the button click I am having this saved:
string strHTMLText = txtPN.Text;
Session["ProgressNoteHTML"] = strHTMLText;
And I am loading it on the postback like this:
txtPN.Text = (string)Session["ProgressNoteHTML"];
ContentPlaceHolder cphMain = (ContentPlaceHolder)this.Master.FindControl("MainContent");
Panel pnlContent = (Panel)cphMain.FindControl("innerFrame");
pnlContent.Visible = false;
Any ideas as to why any postbacks would make the tags appear and in the original page load they do not?
The solution offered by Erik won't work for table tags containing property values. For instance: <table align="right"> will not be decoded. I have also found that <img> tags are encoded by the HTMLEditorExtender as well.
The easier solution is to use the Server.HTMLDecode() method.
TextBox_Editor.Text = Server.HtmlDecode(TextBox_Editor.Text) 'fixes encoding bug in ajax:HTMLEditor
I have the same problem, It seems to have something to do with the default sanitizing that the extension performs on the HTML content. I haven't found a way to switch it off, but the workaround is pretty simple.
Write an Anti-Sanitizing function that replaces the cleansed tags with proper tags. Below is mine written in VB.Net. A C# version would look very similar:
Protected Function FixTableTags(ByVal input As String) As String
'find all the matching cleansed tags and replace them with correct tags.
Dim output As String = input
'replace Cleansed table tags.
output = output.Replace("<table>", "<table>")
output = output.Replace("</table>", "</table>")
output = output.Replace("<tbody>", "<tbody>")
output = output.Replace("</tbody>", "</tbody>")
output = output.Replace("<tr>", "<tr>")
output = output.Replace("<td>", "<td>")
output = output.Replace("</td>", "</td>")
output = output.Replace("</tr>", "</tr>")
Return output
End Function
I'am working with Adobe AIR application and i have a registration form which contains a combobox which consist of 2 values...i want to store the selected value to a variable..
here is the code..
var a:IList = new ArrayCollection(['Nurse','Patient']).list;
selectbox.dataProvider =a;
suppose if it was a textbox,we can store the value like this:-
var lastname:String = textbox2.text;
in the same way how can i store the selected value from combobox...?
Thanks
You'll use the selectedItem property:
var role:String = selectbox.selectedItem;
P.S. Welcome to StackOverflow! If you find my answer helpful, please be sure to 'accept' it by clicking the green checkmark to the left.