473,385 Members | 1,279 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.

Server side functionality

Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete
()" type="button" value="Mark Completed"
name="btnComplete0">

When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script>
I need to perform some server side functinality whenever
user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control
( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the
server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate
to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-Reetu


Nov 17 '05 #1
3 1577
Hi Reetu,

Here's some VB code that might help you. It uses the submit() method. Not sure
why it didn't work for you.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Literal1.Text = "<script>function
onCompleted(){alert('action');document.forms[0].submit();}</script>"
If IsPostBack Then
Label2.Text = "I was posted back at: " & Now.TimeOfDay.ToString
End If
End Sub
<form id="Form1" method="post" runat="server">
<p>
<asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
<p>
<asp:label id="Label2" runat="server"></asp:label></p>
<p>
<asp:label id="Label1" runat="server"></asp:label></p>
<p>
<asp:literal id="Literal1" runat="server"></asp:literal></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<input class="sbttn" id="btnComplete0" onclick="onCompleted()"
type="button" value="Mark Completed"
name="btnComplete0">
</form>
"Reetu" <re***@ascentn.com> wrote in message
news:06****************************@phx.gbl...
Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete
()" type="button" value="Mark Completed"
name="btnComplete0">

When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script>
I need to perform some server side functinality whenever
user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control
( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the
server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate
to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-Reetu



Nov 17 '05 #2
Ram
When your page is loaded, checl the HTML source of your page. Your
hidden button will not be rendered at all.

Instead, you can convert your button to a aspx button and add
Javascript event to it from the code behind using

Add this line of code to your page load event.
ButtonName.Attributes.add("onClick","return onComplete()")

Now when you click on your button it will raise the onclick event on
the client side and will call onComplete Javascript function. Inside
the Javascript if you return false, the form will not be submitted and
the server side event of your button will not fire. If you return
true, form will be submitted to the server and your button's onclick
event will be fired on the server.

----
Ram

"Reetu" <re***@ascentn.com> wrote in message news:<06****************************@phx.gbl>...
Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete
()" type="button" value="Mark Completed"
name="btnComplete0">

When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script>
I need to perform some server side functinality whenever
user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control
( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the
server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate
to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-Reetu

Nov 17 '05 #3

Thanks a lot, it works.

Regards,
-Reetu
-----Original Message-----
When your page is loaded, checl the HTML source of your page. Yourhidden button will not be rendered at all.

Instead, you can convert your button to a aspx button and addJavascript event to it from the code behind using

Add this line of code to your page load event.
ButtonName.Attributes.add("onClick","return onComplete()")

Now when you click on your button it will raise the onclick event onthe client side and will call onComplete Javascript function. Insidethe Javascript if you return false, the form will not be submitted andthe server side event of your button will not fire. If you returntrue, form will be submitted to the server and your button's onclickevent will be fired on the server.

----
Ram

"Reetu" <re***@ascentn.com> wrote in message

news:<06****************************@phx.gbl>...
Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete ()" type="button" value="Mark Completed"
name="btnComplete0">

When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script>
I need to perform some server side functinality whenever user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control ( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-Reetu

.

Nov 17 '05 #4

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

Similar topics

4
by: Steve Bywaters | last post by:
(In my transition from ASP to ASP.NET) *When* would I use at "runat server" tag on a button, as opposed to a normal button? If I set up a search area on a page, with a 'Search' button that...
2
by: Kumar | last post by:
Hi Folks, I would like to develop one custom application using asp.net,C#,SQL server for tracking all our company servers. Most of the functionality is similar to HP Systems Insight Manager ...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
10
by: Ben | last post by:
Hi, I made an application in classic asp (reservation of books and video stuffs for students) and want to migrate to asp.net. The user has to chose a date, then pushung on a submit button. The...
1
by: MPA | last post by:
Hi, We are a small company with no experience in web development. We are considering translating our main client-server product into web application or web service using DOT.NET. Our app is...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
9
by: jazzslider | last post by:
I have a headache. I've done a LOT of research lately into XForms, and I am thoroughly convinced that a good implementation of this technology would help me immensely in converting my...
12
by: Peter Michaux | last post by:
I'm writing a server-side web application framework using Mozilla's Rhino JavaScript engine. My two primary motivations are so I can write code on server and client sides without needing to switch...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.