473,320 Members | 1,991 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,320 software developers and data experts.

Page.ClientScript.RegisterStartupScript

85 64KB
i want to call multiple javascript functions, but only one is being called at a time on the selected index change of drop down list. my C# code is as follows
Expand|Select|Wrap|Line Numbers
  1. protected void ddlSelect_SelectedIndexChanged(object sender, EventArgs e)
  2.         {
  3.             string url = string.Empty;
  4.             if (ddlSelect.SelectedValue != "0")
  5.             {
  6.                 Session["Id"] = ddlSelect.SelectedValue.ToString();
  7.                 url = "Tranlator.aspx?id=" + Session["Id"];
  8.                 if (!ClientScript.IsStartupScriptRegistered("alert"))
  9.                 {
  10.                     Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ViewWithOutAudio();", true);
  11.                     Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "openwindow1('" + url + "');", true);  
  12.                 }
  13.             }
  14.             else
  15.             {
  16.                 Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ViewWithAudio();", true);
  17.             }
  18.         }
  19.  
and my Javascript Functions are as follows
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.             function ViewWithAudio() {
  3.                 var flashvars = {
  4.                     test1: 1
  5.                 };
  6.                 swfobject.embedSWF("ViewVideo.swf", "myContent", "400", "200", "9.0.0", "expressInstall.swf", flashvars);
  7.             }
  8.         </script>
  9.  
  10.         <script type="text/javascript">
  11.             function ViewWithOutAudio() {
  12.                 var flashvars = {
  13.                     test1: 1
  14.                 };
  15.                 swfobject.embedSWF("ViewVideoWithoutAudio.swf", "myContent", "400", "200", "9.0.0", "expressInstall.swf", flashvars);
  16.             }
  17.         </script>
  18.  
  19.          <script language="javascript" type="text/javascript">
  20.              function openwindow1(url) {
  21.                 window.open(url);
  22.  
  23.              }
  24.     </script>
  25.  
Aug 16 '12 #1
5 9220
ariful alam
185 100+
I am not sure, but can you try the following. two scripts in one line.

Expand|Select|Wrap|Line Numbers
  1. Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ViewWithOutAudio(); openwindow1('" + url + "');", true);
Hope works. :)
Aug 16 '12 #2
Mudassir
85 64KB
i used RegisterClientScript instead of RegisterStartupScript and it worked.. anyhow thnx for your suggestion, i will try this too
...
Addan
Aug 16 '12 #3
Frinavale
9,735 Expert Mod 8TB
Lines 10 and 11 in the first code block you posted in your original post...

You are setting the name of the script to the same thing for both scripts. Consider changing this so that they have different names.


-Frinny
Aug 16 '12 #4
Mudassir
85 64KB
@Frinny:
will you please elaborate a little bit , i did not get your point, i have two functions with different names one is ViewVideoWithoutAudio and the other one is OpenWindow1.
...
Addan
Aug 16 '12 #5
Frinavale
9,735 Expert Mod 8TB
These are lines 10 and 11:
Expand|Select|Wrap|Line Numbers
  1. Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ViewWithOutAudio();", true);
  2.  
  3. Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "openwindow1('" + url + "');", true);  
Notice the second parameter is both "alert" for both lines?

It may not fix your problem but these these should the second parameter (the name of the script) should be unique for each script.

I think you may be overwriting scripts.
Aug 16 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: sck10 | last post by:
Hello, I have the following sub in a class in my "App_Code" directory. The script is for setting focus on a particular control, but I get the error, "Name ClientScript Not declared". Also, I am...
3
by: sck10 | last post by:
Hello, I am trying to set the focus on an object using the following: However, I am getting the following error: The name Clientscript does not exist in the current context. protected void...
9
by: C | last post by:
Hi, On a click event of a button I do some validation. If my validation is unsuccessful I display an alert to the user as below. string message = "This is a test alert.";...
4
by: Jon Paal | last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object reference". ... what reference is it looking for ?????? class...
3
by: First Last | last post by:
Hi, Newbie question: Why use Page.ClientScript.RegisterClientScript* when we can just make a .js file and include a reference to it in the page? (i.e. <script src="myscript.js"...
3
by: Wayne Deleersnyder | last post by:
Hi All, I'm trying to create a function that will cause a pop-up alert to appear if dates which were chosen from a drop-down list were invalid on a page. There's 4 dates, so there's the...
1
by: HockeyFan | last post by:
My function to get an alert box on the page isn't working. Instead it puts in the bottom section of the page: <script type="text/javascript"> <!-- This is a test// --> </script> The...
2
by: =?Utf-8?B?Qw==?= | last post by:
Hi, I have a 3 dimenionsal array which I populate in my C# code. I then want to make this available to my Javascript so I do below. Page.ClientScript.RegisterArrayDeclaration("myArray",...
0
by: =?Utf-8?B?QW50b25pbw==?= | last post by:
Hello, everyone. I am trying to open a popup page to display some information but it is not working. Going through the code, no errors are generated. It goes to the end of the code but it does...
9
by: 0301102 | last post by:
I using following script in my project. Once click the button and there will open a pop up window. But "Page.ClientScript.RegisterStartupScript" script seem NOT working in update panel. After remove...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.