473,563 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function samples

in the visual studio .NET samples that come with the product, why do
javascript functions all have the parameters below. Even though, the event
(like Onclick) which is calling it doesn't have any parameters.

private function somename(sender :Object, e:EventArgs)

thanks.

Nov 18 '05 #1
3 2315
I belive you are confusing a server OnClick event with a client side onclick
event. The OnClick(s as object, e as eventargs) is for server side stuff.
"Mark Kurten" <ma*********@ac ordia.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
in the visual studio .NET samples that come with the product, why do
javascript functions all have the parameters below. Even though, the event (like Onclick) which is calling it doesn't have any parameters.

private function somename(sender :Object, e:EventArgs)

thanks.

Nov 18 '05 #2
Hi Mark,
Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you'd like to know why there are some script
function in the page's source file and they have some parameters declared,
however, in the control's event attribute, the calling function don't take
any parameter such as:
private function somename(sender :Object, e:EventArgs)
{
......
}

and we use this fuction for a control 's "OnClick" event like:
<asp:Button id="btn" OnClick="somena me" />

If there is anything I misunderstood, please feel free to let me know.

As for this question, I think it i because the different program style of
clientside script block and serverside code block:
1.Generally, if we develop the ASP.NET page in VS.NET, when we create a web
page, the IDE will help use create a code-hehind class file together with
the page. Then, we can write the serverside event handler, such as server
control's click even's handler in the code-behind class file(.aspx.cs or
..aspx.vb files). For example:
private void Page_Load(objec t sender, System.EventArg s e) // page's click
event handler
{
............... .

}

private void btnPrint_Click( object sender, System.EventArg s e) // a certain
button's click handler
{
............... .

}

these serverside event handlers normally all take two paramteres,one
(sender) is the source of the event, and the other (e, EventArgs or its
derived class) contains some infos of the event. When we add the handler to
a certain control's event's handler collection, we only need to provide the
function's name , not argument list needed, for example:

this.btnPrint.C lick += new System.EventHan dler(this.btnPr int_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

However, if we don't use the code-behind page class file, then we just
write these handler functions in the aspx file and in such code blocks as
below:
<script language="C#" runat="server">
.....
private void btnPrint_Click( object sender, System.EventArg s e) // a certain
button's click handler
{
............... .

}
</script>

and we also speify the handler for a ASP.NET server control in the file
like:
<asp:button id="btnPrint" runat="server" Text="Print"
OnClick="btnPri nt_Click"></asp:button>
Just the function name, no parameter needed. Since the ASP.NET runtime will
help you to generate the "sender" and "e" object from the control
automaitcally.
For more detailed info on event handler in ASP.NET serverside , you may
view the following reference in MSDN:
http://msdn.microsoft.com/library/en...andlers.asp?fr
ame=true

#Creating Event Handlers in Web Forms Pages
http://msdn.microsoft.com/library/en...ngEventHandler
sInWebFormsPage s.asp?frame=tru e
2. The function I discussed in 1. is the server side code in ASP.NET. In
addition, we can write client side script code such as javascript in the
aspx page source file, for example:
<script language="javas cript">
function jsfn()
{
alert("hello world!");
}

function sayHello(name)
{
alert("hello world" + name);
}
</script>

But be careful, such client side script is quite different from the
serverside code, they only runat the client's browser. You can see the
<script ..> block doesn't have "runat=serv er". And the client side script's
function could also take paramter or doesn't take parameter. I've shown the
two condition in the above example.
If you need more information on clientside scripting, you may view the
following link for reference:

#javascript overview and examples
http://msdn.microsoft.com/library/en...t.asp?frame=tr
ue
Please check out the above items to see whether they help. If you need any
further assistance, please feel free to let me know.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
thank you very much for the detailed explanation...

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:C1******** ******@cpmsftng xa07.phx.gbl...
Hi Mark,
Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you'd like to know why there are some script
function in the page's source file and they have some parameters declared,
however, in the control's event attribute, the calling function don't take
any parameter such as:
private function somename(sender :Object, e:EventArgs)
{
.....
}

and we use this fuction for a control 's "OnClick" event like:
<asp:Button id="btn" OnClick="somena me" />

If there is anything I misunderstood, please feel free to let me know.

As for this question, I think it i because the different program style of
clientside script block and serverside code block:
1.Generally, if we develop the ASP.NET page in VS.NET, when we create a web page, the IDE will help use create a code-hehind class file together with
the page. Then, we can write the serverside event handler, such as server
control's click even's handler in the code-behind class file(.aspx.cs or
aspx.vb files). For example:
private void Page_Load(objec t sender, System.EventArg s e) // page's click
event handler
{
...............

}

private void btnPrint_Click( object sender, System.EventArg s e) // a certain button's click handler
{
...............

}

these serverside event handlers normally all take two paramteres,one
(sender) is the source of the event, and the other (e, EventArgs or its
derived class) contains some infos of the event. When we add the handler to a certain control's event's handler collection, we only need to provide the function's name , not argument list needed, for example:

this.btnPrint.C lick += new System.EventHan dler(this.btnPr int_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

However, if we don't use the code-behind page class file, then we just
write these handler functions in the aspx file and in such code blocks as
below:
<script language="C#" runat="server">
....
private void btnPrint_Click( object sender, System.EventArg s e) // a certain button's click handler
{
...............

}
</script>

and we also speify the handler for a ASP.NET server control in the file
like:
<asp:button id="btnPrint" runat="server" Text="Print"
OnClick="btnPri nt_Click"></asp:button>
Just the function name, no parameter needed. Since the ASP.NET runtime will help you to generate the "sender" and "e" object from the control
automaitcally.
For more detailed info on event handler in ASP.NET serverside , you may
view the following reference in MSDN:
http://msdn.microsoft.com/library/en...andlers.asp?fr ame=true

#Creating Event Handlers in Web Forms Pages
http://msdn.microsoft.com/library/en...ngEventHandler sInWebFormsPage s.asp?frame=tru e
2. The function I discussed in 1. is the server side code in ASP.NET. In
addition, we can write client side script code such as javascript in the
aspx page source file, for example:
<script language="javas cript">
function jsfn()
{
alert("hello world!");
}

function sayHello(name)
{
alert("hello world" + name);
}
</script>

But be careful, such client side script is quite different from the
serverside code, they only runat the client's browser. You can see the
<script ..> block doesn't have "runat=serv er". And the client side script's function could also take paramter or doesn't take parameter. I've shown the two condition in the above example.
If you need more information on clientside scripting, you may view the
following link for reference:

#javascript overview and examples
http://msdn.microsoft.com/library/en...t.asp?frame=tr ue
Please check out the above items to see whether they help. If you need any
further assistance, please feel free to let me know.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4

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

Similar topics

9
3680
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people discuss how reflection does this, but I cannot find the syntax to do this. I have tried several code example off of gotdotnet and other articles. Can...
1
2300
by: Fisch von Gestern | last post by:
I have tried to run the extension function/element examples provided with the Xalan-J download. I believe that my classpath is correct, and that my versions are up-to-date. However, I can't get past the following error. Any help, please? =========================================================================== C:\xalan>test ...
0
1807
by: EasyRider41 | last post by:
I am trying to merge to scripting samples I for on a source code web site and having limited luck. Then first one is called Zebra Tables witch colors alternate rows of a table to look beter. The second is a rule code that highlights the row you are currently moused over. Both are making use of CSS style sheet to do all of their formating. My...
0
2912
by: Sean Newton | last post by:
I am absolutely bewildered by now by the Microsoft.Samples SSPI and Security assemblies. I've been trying to set these up in a very straightforward harness in the way that I'd like to be able to use them. No IIS. Use TCP, binary. Standard server example with a console host and console client. .NET 1.1, windows XP. (I tried posting to the...
10
18563
by: Mamuninfo | last post by:
Hello, Have any function in the DB2 database that can generate unique id for each string like oracle, mysql,sybase,sqlserver database. In mysql:- select md5(concat_ws("Row name")) from tablename; Here this function generate unique id for each row of the table. Regards..
10
1575
by: Don Wash | last post by:
Hi! I'm pretty frustrated learning ASP.NET. I'm learning ASP.NET by downloading samples from various ASP.NET websites and none of the samples worked so far. The SAME error was shown whenever I browse and ASP.NET sample, which is... So I'm getting 'Could not load type <<Class Name>>' error for any ASP.NET
4
1914
by: shachar | last post by:
hi all. i'm looking for a simple example of how to pass optionaly, an array to a function. if the array isn't there (it's optional) i want to know about it. thanks.
1
11423
by: David Lozzi | last post by:
Hello, I have a user control that saves data. When the data is saved, I need to call a function in the parent page from the user control to initiate something else. I know I can set it up so that the save button is in the parent page and calls the save function of the user control and then whatever I need from the parent page, but I'd...
89
5968
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be used." Could anybody tell me why gets() function is dangerous?? Thank you very much. Cuthbert
28
4294
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
0
7665
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, 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...
0
7583
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...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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...
1
2082
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
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.