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

Javascript being called from ASP with c# codebehind.....Problemo

Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:
<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModalDialog(
"dialogBox.aspx", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQuery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS" runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>
BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.
Many Thanks guys, for your help, I dont know where else to turn!!!
Nov 16 '05 #1
3 1867
You can attach javascript to an asp button in the codebehind like this:

myButton.Attributes.Add("onclick", "openquery()");

-Jason

nazim wrote:
Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:
<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModalDialog(
"dialogBox.aspx", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQuery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS" runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>
BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.
Many Thanks guys, for your help, I dont know where else to turn!!!

Nov 16 '05 #2
Jason DeFontes <ja***@defontes.com> wrote in message news:<uK**************@TK2MSFTNGP11.phx.gbl>...
You can attach javascript to an asp button in the codebehind like this:

myButton.Attributes.Add("onclick", "openquery()");

-Jason
I've actually used that and yes it allows me to call the java script
but ONLY when the I remove/comment out the <form> tags [as shown
below]. Now sorry if its a silly question but I need the form tag for
future server side processing?
I cant just omit them from the future webpage, thats why I was stuck.

Any ideas???
nazim wrote:
Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:
<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModalDialog(
"dialogBox.aspx", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQuery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS" runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>
BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.
Many Thanks guys, for your help, I dont know where else to turn!!!

Nov 16 '05 #3
the framework gets all the data via the post.
you need the form tag.
I've actually used that and yes it allows me to call the java script
but ONLY when the I remove/comment out the <form> tags [as shown
below]. Now sorry if its a silly question but I need the form tag for
future server side processing?
I cant just omit them from the future webpage, thats why I was stuck.

Any ideas???

Nov 16 '05 #4

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

Similar topics

0
by: Prescott | last post by:
I want to execute a javascript function that will set a value in the parent window from the child widow where its called and then post the form to the server. I seem to be able to execute one or...
0
by: Scott Wallace | last post by:
I have a page that displays several pictures pulled from a database. I want any one of the pictures to appear in a larger main picture container when the user clicks on it. I want to do this on the...
5
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
7
by: =?Utf-8?B?Qw==?= | last post by:
I have a dropdown list as below. I add an onchnage attribute in my codebehind to call some Javascript. I want to get the selected text from my dropdown. What am I doing wrong below? ...
2
Frinavale
by: Frinavale | last post by:
I am attempting to use embedded resources in an Ajax Enabled ASP.NET Web Application. I'm using Visual Studio 2008 and VB.NET server side code. The project is called "EmbeddedResources" with the...
4
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hi, I have an ASP .NET page with codebehind in a vb file. The page has a dropdown control, and a JS function which used HTTP XML Request to get the data from the database, and populate the...
4
by: archana | last post by:
Hi all, i am having one user control. what i want is to add javascript which will gets called on button click of user control. but user control is not working if i add javascript in user...
1
by: ahmh | last post by:
The javascript function is called getsportart2 in the codebehind page_load I have the following Page.RegisterStartupScript("MyScript3","<script type='text/javascript'...
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
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...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.