SetAttribute not working in WebBrowser Control - c#

I am developing automation windows application in C# using web browser control.
To set the values to the controls, I am using SetAttribute property.
It works fine for all the controls but the text box which consist watermarking
For example
The following is my coding
WebBrowser.Document.GetElementById("ctl00_Content1_dob_txbx").SetAttribute("value", "09/17/1976");
While running the application, the textbox holds the value like watermarking
For example
while clicking the submit button the date getting vanish. How can I set the date in the watermarking text box?
How can I achieve the following output
Note:
In the website the Watermark achieved by ajax WatermarkExtender

I have found the solution
I have set the value in WebBrowser_ProgressChanged event now its works fine
private void automationWebBrowser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
if (automationWebBrowser.Document.GetElementById("ctl00_Content1_dob_txbx") != null)
automationWebBrowser.Document.GetElementById("ctl00_Content1_dob_txbx").SetAttribute("value", "09/17/1976");
}

Related

Update PDF in windows form without losing focus

I'm developing a PDF creator using Windows Forms application in Visual Studio Community 2017. I'm using MigraDoc to generate PDFs and they are directly created by a series of data inserted by the user in textboxes.
The page for inserting and displaying the data is the same, because I want a real time update of the PDF document preview. To display the PDF I'm using an axAcroPDF element obtained in the COM section after the installation of Adobe Reader.
In order to update the PDF document I have written a class that simply introduces the new elements (I use a Leave event trigger on textboxes to call the update) and load the new PDF file inside the axAcroPDF element:
axAcroPDF1.LoadFile(filename);
The problem is the fact that each time I insert new data in one of the textboxes and the leave event is triggered it is like the entire form is reloaded and I lose focus on the textbox I was writing on (data inserted remains but the focus gets totally lost and the writing cursor is not preserved). This happens to the other textboxes if I click on another one or if I use tab to move to the next one. Notice that the PDF is correctly updated. Is there any method to avoid this problem and update the PDF section without losing focus on textboxes? Is it also possible doing that on a changetext event listener for those textboxes?
Here is an extract of the code use. The function updateText is called when a changetext event is detected on the textbox:
private void updateText(object sender, EventArgs e)
{
updateDocument();
axAcroPDF1.LoadFile(filename);
TextBox s = (TextBox)sender;
s.Focus();
}

Show virtual keyboard when text box in any application is clicked C#

I'm making a c# windows application that will make it possible to fully control your windows computer via a gaming controller only. Right now I'm done with mouse control coding and I'm testing for bugs. What I want next is to create a virtual keyboard which shows up when a text box in any application is clicked. For example, the android keyboard which only appears when you need it. I have searched and the only thing I have found so far is how to call a function only when the text box is in the same Form. My question is if there is a way to make a listener when a textbox is clicked for all open programs. I would appreciate any help.
You should send the code or integer between forms when user click on the textbox using code like :
public string _label3
{
get { return label3.Text; }
}
you write value and send it to other form then receive it using set method.
public string _label3
{
set { return label1.Text; }
}
Using timer to watch coming value all time or check for label1.text then, when u receive this value
using this code to open virtual Keyboard.
System.Diagnostics.Process.Start("osk.exe");

How to Show Other Forms Using DevExpress tileItem in tileControl?

I am new in C# and DevExpress. I'm trying to show another form by clicking a tile in the tileControl group but it doesn't show up. I just right-clicked at the tileControl, clicked view code and manually declared this since this doesn't automatically shows up if you double click a tile.
private void addTile_Click(object sender, EventArgs e)
{
var xForm2 = new XtraForm2();
xForm2.Show();
}
I just right-clicked at the tileControl, clicked view code and manually declared this since this doesn't automatically shows up if you double click a tile.
If I understand this correctly, you did not build your project using the C# code listed above, but only edited the source.
That does not work because what you edit in this way is not being loaded into the app.
Of course, I could be misunderstanding what you wrote.

How can I select all the text within a Windows Forms textbox?

I want to select all the text that is with in text box.
I've tried this using the code below:
textBoxResults.SelectionStart = 0;
textBoxResults.SelectionLength = textBoxResults.Text.Length;
Source: I got this code from here http://msdn.microsoft.com/en-us/library/vstudio/hk09zy8f(v=vs.100).aspx
but for some reason it doesn't seem to work - meaning, no text gets selected.
You can use the built in method for this purpose.
textBoxResults.SelectAll();
textBoxResults.Focus(); //you need to call this to show selection if it doesn't has focus
You can also try the following which might solve you problem:
textBoxResults.SelectAll();
This works well with multi-lined textbox.
This method enables you to select all text within the control.
public void CopyAllMyText()
{
// Determine if any text is selected in the TextBox control.
if(textBox1.SelectionLength == 0)
// Select all text in the text box.
textBox1.SelectAll();
// Copy the contents of the control to the Clipboard.
textBox1.Copy();
}
Check this link for more info. http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectall.aspx

What winforms control to display message with minor html formatting?

Is there a control I can use to display a short message that contains minor html formatting (eg one or more links). I'd prefer not to use the WebBrowser control (suggested here) as it's a bit heavy for what I want, so any other suggestions welcome.
If a user does click a link from my message I want it to be opened in their default browser, not within my application.
I do use the infragistics controls so one of those would be fine but I don't see any that will do this.
You can use the controls in this article on CodeProject or you can use them as an example for how to roll your own.
I have implemented an HTML control for .NET which may do what you want: see http://www.modeltext.com/html for details.
The control can display HTML including links, and doesn't use a browser.
What happens when the user clicks on a link is up to you: the control generates an event, which can be handled by the application in which the control is embedded; so, your application would instantiate the control, fill it with HTML, install an event handler, and launch the browser when its event handler is told that the user has clicked on a link.
If all you need is the link functionality you can use the LinkLabel control. Assuming that you have set the LinkLabel.Tag property to the url the following code will open the default browser and open the specified web page:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start((string) ((sender as LinkLabel).Tag));
}
I think the best solution in my case might be to use RichTextBox, which has a property DetectLinks and a LinkClicked event that tells you which link is clicked. I'll look into this further...

Categories