Hii all ,
desperately looking for help.
i want to execute one java script function,passva lues(), which is there in my master page.
After doing so much of additions , subtraction and type conversions in the button click event im obataining the values for 3 variables which i need to pass these values to the existing javascript function...how can i pass these values to the javascript function which is thr in master page ..in the end of the button_click event handler.. - Protected void Button_Click(sender object,EventArgs e)
-
{
-
// Type conversions..
-
//getting the references of other control..
-
blah blah blah
-
-
value1="";
-
value2="";
-
value3="";
-
-
/*Now i want to pass these values to a javascript function which is there in my master page..based on these values only all my remaining functions work.*/
-
}
Requesting you all Kindly suggest me the solution .
Is Clientmanager.R egisterStartupS cript will work for me ...if yes kindly tell me how can i use tht .
Thanks in advance..
Rgds,
BTR.
7 10640 Dormilich 8,658
Recognized Expert Moderator Expert
to me it looks more like Java....
hey NO ,im using ASP.NET and C#.
Dormilich 8,658
Recognized Expert Moderator Expert
well, then it is C#. if this is a problem in C# programming, maybe it's better to ask in the C#-forum.
thts not a JavaScript Function..thts an EventHandler in C#..for understanding purpose only i mentioned it there.
leave any syntax errors if you find..but plz understand the problem and suggest me the solution.
Thank you..
Rgds.,
BTR.
acoder 16,027
Recognized Expert Moderator MVP
Since no-one here has much experience with ASP.NET and C#, we can only show you how to use JavaScript in a normal HTML page.
The basic idea is that you need to generate the JavaScript code using the server-side language. How you do that would differ from language to language.
Frinavale 9,735
Recognized Expert Moderator Expert
I see no JavaScript posted above.
I'm a little confused as to what you're trying to do...
Are you trying call a JavaScript function when you click an ASP.NET button?
You need to add the JavaScript to the page (you are doing this by using the RegisterStartup Script method). This will make the JavaScript function available to be used client side (in the web browser).
You cannot use JavaScript code in your C# code....simply because JavaScript code is executed client side (in the web browser) and your C# code is executed on the server.
So, in order to use the JavaScript function, you need to call the JavaScript code during the JavaScript "onclick" event....not in the C# OnClick event.
To do this you add an attribute to the button: -
myButton.Attributes.Add("onclick","myJavaScriptFunction()");
The above code adds a JavaScript "onclick" to your button...so now when the user clicks the button your JavaScript method is executed.
I tend to put this code in the PreRender event...you only need to set this the first time the page is loaded (so long as your button and page have viewstate enabled).
So, in the PreRender event (or PageLoad event) you would have something like (C# code): -
if(isPostBack==false)
-
{
-
myButton.Attributes.Add("onclick","myJavaScriptFunction()");
-
}
Please check out this article about how to use JavaScript in ASP.NET and the article named how to check if a TextBox contains a number for more information.
well u need 2 get few references and use raisecallbackEv ent(). see if u can get somethin from below lines : - Protected void Button_Click(sender object,EventArgs e)
-
{
-
// Get javascript function from the
-
// server that is capable of connecting
-
// to our server. RecieveServerData is
-
// the javascript method we will call when
-
// we are done processing the data
-
string reference =
-
this.ClientScript.GetCallbackEventReference(
-
this, "arg", "RecieveServerData", "");
-
-
// Generate the javascript that can connect
-
// to the server
-
string callBackScript =
-
@" function CallServer(arg, context)
-
{" + reference + ";}";
-
-
// Put the javascript on the page
-
this.ClientScript.RegisterClientScriptBlock(
-
this.GetType(), "CallServer",
-
callBackScript, true);
-
}
-
-
///
-
/// This is the method called by the
-
/// javascript. Here you can do some server
-
/// processing to manage what you are going
-
/// to give back to the client if anything.
-
///
-
///
-
public void RaiseCallbackEvent(
-
string eventArgument)
-
{
-
/* Im saving stuff here */
-
this.fromClient = eventArgument;
-
}
-
-
///
-
/// This is the method that passes back
-
/// to the javascript.
-
///
-
///
-
public string GetCallbackResult()
-
{
-
return this.fromClient;
-
}
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: tshad |
last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an
asp.net problem or a javascript problem.
I have a page that was originally created from a program I found on the net
that works well as an html page.
It brings up a modal popup window that I have been trying to work out for
days now and this was the closest I...
|
by: Michelle Keys |
last post by:
I am trying to call a print function to print a string from a database
using javascript.
Which is RC_DATA of Varchar2(2500).
This is a javascript is not being used. I have a thing that needs to be
modified:
if(e.CommandName =="Print")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells.Text);
Session =...
|
by: jm |
last post by:
I have a parent window:
<script language="javascript">
function doSearch() {
result=showModalDialog("searchmni.aspx?lastname=smith");
alert(result);
}
</script>
|
by: Julia |
last post by:
Hi Everyone,
I am using webbrowser control to post data to an aspx page. However, for
some reason, the aspx page sometimes will execute page_load event twice, and
sometimes execute it once. So I might get different results for executing it.
If I have the webbrwoser control to call it the first time, the aspx will
usually execute the...
|
by: Scott Natwick |
last post by:
Is there a way to execute a JavaScript from the Page_Load event?
Or alternatively, is there a way to have it execute when the page is loaded?
I am defining the script in the Page_Load event and using the
RegisterStartupFunction to add it to the page. I just need a way to execute
the script when the page loads.
Any ideas?
| |
by: Ian Kelly |
last post by:
Hi All,
I have an .net form that is split into two frames. The left frame has a
tree that displays a list of all the customers. The right frame displays
the appropriate clients information. When the save button is pressed on the
right frame, I want to update the tree in the left frame AFTER saving all
the data as the changes to the right...
|
by: oliver |
last post by:
QUESTION: How to access an object embedded in a UserControl through
Javascript file?
Another way to ask this question: How to execute script from a UserControl,
accessing other objects in that UserControl? (Script attached to, and
executed by, a UserControl embedded server control can ‘see’ the UserControl
through the root document...
|
by: Veerle |
last post by:
Hi,
I have a web page and at the end of the page I have inserted some
javascript that checks if Acrobat Reader plugin is installed. If it is
not installed, I disable some elements (buttons, checkboxes, ...) on
the page. This javascript is at the end of the page, because
javascript cannot identify html elements if they are defined below the...
|
by: Matthew Wells |
last post by:
OK, I've narrowed down the problem. This works when in the aspx page
<script type="text/javascript" >
function btnFirst_Click()
{
alert("Hello");
alert(document.getElementById("<%=LBFacilities.ClientID%>").options.length);
return false;
}
</script>
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |