473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to call a javascript method from XAML

Hi,

How to call a javascript method from XAML. I am using C# .

In the following example, When I click button1, I wish to call a
method by name "SetValue(somevalue)"
of TestIndex.html file. Here SetValue is a javascript method present
in TestIndex.htm file.

Let me know if you need any further information.

Thanks in Advance.

Thanks
Tarini
----------------------------

<Window x:Class="wpfsample1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="wpfsample1" Height="755" Width="1032"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.121785006260434*" />
<ColumnDefinition Width="0.0273246391943384*" />
<ColumnDefinition Width="0.36610333628965*" />
<ColumnDefinition Width="0.484787018255578*" />
</Grid.ColumnDefinitions>
<Button Height="23" Margin="63,83,18.3874239350913,0"
Name="button1" VerticalAlignment="Top" Click="OnBtnClick">Button</
Button>
<Frame Content="Frame" Margin="13.3874239350913,3,69,1"
Name="frame1" Source="http://localhost/TestIndex.html" Grid.Column="2"
Grid.ColumnSpan="2" />

</Grid>
</Window>

May 18 '07 #1
2 4664
AFAIK, the Frame content is isolated from the outer content and cannot call
the JS script.

"ta*****@gmail.com" wrote:
Hi,

How to call a javascript method from XAML. I am using C# .

In the following example, When I click button1, I wish to call a
method by name "SetValue(somevalue)"
of TestIndex.html file. Here SetValue is a javascript method present
in TestIndex.htm file.

Let me know if you need any further information.

Thanks in Advance.

Thanks
Tarini
----------------------------

<Window x:Class="wpfsample1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="wpfsample1" Height="755" Width="1032"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.121785006260434*" />
<ColumnDefinition Width="0.0273246391943384*" />
<ColumnDefinition Width="0.36610333628965*" />
<ColumnDefinition Width="0.484787018255578*" />
</Grid.ColumnDefinitions>
<Button Height="23" Margin="63,83,18.3874239350913,0"
Name="button1" VerticalAlignment="Top" Click="OnBtnClick">Button</
Button>
<Frame Content="Frame" Margin="13.3874239350913,3,69,1"
Name="frame1" Source="http://localhost/TestIndex.html" Grid.Column="2"
Grid.ColumnSpan="2" />

</Grid>
</Window>

May 19 '07 #2
You can only do it id both pages are on the same domain.
To call a function inside a frame:
document.getElementById("frame_id").contentWindow. myFunction();

.... and to call a function in the parent window:
window.parent.myFunction();

Diego
May 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Thilaka | last post by:
Hi guys, Recently i read some articles on Longhorn & XAML. & From what i learnt the future for developing UIs lies in XAML. Does this mean that I've got to learn XAML as developing UIs for web...
13
by: Jeff | last post by:
How important is XAML? (or how important is it expected to become during the next 5 years?) Looking for informed opinions. Thanks!
7
by: GVN | last post by:
Hi All, I would like to write a .NET application which uses XAML. The following is my system's specification: Operating System : Windows XP ..NET Framework : 1.1
3
by: Brent | last post by:
OK i downloaded the new/addon framework 3 and downloaded the VS 2005 addon. I started with XAML. So far im like mehhhhhhhh. Anyone else have the same opinion? When i first heard about xaml i got...
1
by: =?Utf-8?B?b3JpYXpvd2Fu?= | last post by:
Hi, Im just getting into the beutifull world of .NET framework 3.0. But im a little confused about the sample codes i have seen so far. Im particularly interested in document layout and auto...
6
by: moondaddy | last post by:
will CodeDom create XAML windows or just regular windows forms? If so, how to I tell it to create a xaml window instead of a windows form? thanks -- moondaddy@noemail.noemail
0
by: =?Utf-8?B?WmlnZ3lTaG9ydA==?= | last post by:
I have a sample XAML file: <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <Button Name="button2" Height="23" Width="300" Margin="31,37,0,0" Click="doit">Hello...
6
by: star-italia | last post by:
Hi, Is it possible to include a XAML file into another XAML file? For example If i have - Window1.xaml - Window2.xaml and both have a treeview with a custom Style, can i describe the style...
4
by: moondaddy | last post by:
I have a user control located in the following path: projectFolder/PropertyControls/myControl.xaml and in myControl.xaml I have a reference to a resource dictionary like this: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.