Auto fill form in Silverlight OOB - silverlight

I have a Silverlight Out-of-Browser (OOB) application which has a WebBrowser control inside it. Displayed website in inner web browser comes from the different domain than the application xap file. How could I automatically fill form displayed in the inner browser? Preferably directly with Silverlight, or JavaScript.
I have tried to invoke external JavaScript code from silverlight application:
webBrowser.InvokeScript ("eval", "document.getElementById('formField1').value = 'value1';" +
"document.getElementById('formField2').value = 'value2';"+
"document.forms[0].submit();");
Apparently Silverlight limits this functionality due to the security reasons (Cross-site scripting I think).
WebBrowser.InvokeScript
Executes the specified script, which is defined in the currently loaded HTML.
Since my JS code is not loaded in the HTML that is currently displayed in the web browser control I can't use this approach.
Most obvious solution is to modify target website to contain my JS code. But I would like to hear some other options.

Related

IFrame on Silverllight

I want to add IFrame to my Silverlight web site. and into that iframe i want to add aspx page. is that possible? (aspx page in silverlight.)
It's posible in your HTML where you call the Silverlight xap file, but not inside Silverlight itself
Yes you can add what ever asp / html elements to the web page where your silverlight application is running.
For example modify the ProjectNameTestPage.aspx in your web project.
Actually it is possible to have HTML content nested within the Silverlight, Telerik for example has a control called "HtmlWindow" or "RadWindow" which does just this. Either you could subscribe to their control set or try and find out how they did it.
I have used Telerik's control multiple times in an MEF Silverlight application where different web applications (SSRS for example) are contained with the MEF plugins.

Embed another xaml silverlight object in page

I am totally to Silverlight and am Getting started. I finished the first of the Getting started series here and now seeing into HTML Bridge now over here. Visual Studio created a website for me when it created the new silverlight application. For the HTML bridge tutorial I created another silverlight page(Is this what i should create) and put some code into it.
Question
How do I embed this into a html page? ( I know how to do it using markup as well as javascript, I am confused as to how to get the application out of single xap file inside ClientBin directory)
With Silverlight you are dealing with a single plugin within a HTML page. That plugin is the single XAP file that the HTML page downloads.
Your Silverlight app may also have many pages, but its navigation is not the same as HTML navigation (it uses bookmark URLs to fool the browser into staying on the same page while it changes content). There is only the one HTML page involved.
Initially, just to test your new page, you can change the app.xaml.cs file to create your new Silverlight Page instead of RootVisual = new Main() etc. Long term you need one Silverlight application per separate plugin your require.
Update (from comments):
Pages in Silverlight are changed by substituting a visual element of the single main page with the contents of another Silverlight page.
You cannot simply replace the RootVisual (as that can only be set at startup).
Start with a new Navigation or Business application project to see the basics (navigation adds a lot of complexity, but once you see how it works it is pretty cool).

What if we don't host our silverlight Application when we first Create it?

As we all know very well..
whenever we create application inside silverlight it is asking us for hosting it
by dialogue box at given below.
My question is what if i unchecked the check box[Host the silverlight application in a new web site].
Means what kind of problem we have to face later if I don't host our Silverlight Application in any of the option given by dialogue box.
Basically it is not a problem at all. You can add a website at any time later.
In the project settings of a website there is a Silverlight tab. Under that you will find the option to add Silverlight projects to the website. This will setup the links to generate the XAP in ClientBin as well as giving you the option to create test pages for each Silverlight app added. The test pages will give you the sample JS you need to host your Xap later.
You will have to eventually host your application somewhere otherwise it will stay on your local harddrive and hardly reach any clients. So if you have an existing web site you could simply copy-paste the necessary javascript to this site later in order to embed your Silverlight application. In this case you can uncheck this checkbox.

can we add silverlight application in tool box of asp.net web application

can we add silverlight application to tool box of asp.net web form application so that instead of writing HTML to include silverlight application i can just drag n drop it from tool box.
You can't add a silverlight app directly to the tool box. However its fairly simple to create a WebControl whose Render method writes out the appropriate <object> element with the source param pointing at your applications xap.
You can even add some properties from which that your render code could generate an initparams <param> element.
This WebControl would automatically end up in the ToolBox allowing you to drag it on the design surface.
You might even consider detecting that the control is rendering in the design time and change the output to display a reasonable placemarker for it in the designer.
Some versions ago Silverlight had a Silverlight Server control.
There is still one available here.

TestPage.aspx in silverlight

I am a beginner in silverlight. I want to know what is TestPage.aspx and TestPage.html in silverlight. Actually i have google it but din't get enough information. Can any one give me answer??
TestPage.aspx and TestPage.html are the pages which will host your Silverlight content. As you might know, Silverlight is just a project (not a web application) and needs a page that can host it.
These pages are created by default and help you to test your XAML content during your development, which you can later remove from your project.
TestPage.html is dynamically generated by the Silverlight application as part of the Debug process. If you take a look at the Debug tab for the application properties you will see an option to Dynamically generate a test page. If this is selected then you TestPage.html is created in the /Bin/Debug folder of your Silverlight application.
A better solution is to create a web application in the same solution as your Silverlight application then in the properties for the web application go to the Silverlight Applications tab and add your existing Silverlight app to the web project. Also make sure that the Silverlight checkbox is ticked in the Debuggers section of the Web tab of your web application.

Resources