.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Saving data in javascript from codebehind and use data in other javascript functions

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

In the Page_Load event I want to write some data in javascript which can be used later via a javascript function.

Protected Sub Page_Load
'get data from database
    SELECT * FROM locations
'write the data in javascript
    Me.Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "ScriptKey", "var sDataArray = MultiDimensionalArray(0, 3);sDataArray[0][0]='THIS IS SOME DATA';", True)

End Sub

Then in the ActiveTabChanged event of the tabcontrol I want to use that data:

 function ActiveTabChanged(sender, e) {
     if (sender.get_activeTabIndex() == 1) {
         __doPostBack(sender.get_id(), sender.get_activeTabIndex());
 How can this be done?

View Complete Post

More Related Resource Links

showing modalpopup and saving data to database simultaneously using ajaxtoolkit and javascript

hi,i have a button ,i want that when i click on that button the data should be saved in the database as well as at the same time a modal popup should display the customerid .i have written the code as <asp:button id="save1" runat="server" onclick="Button4_Click" style=""z-index:" mode="hold" xmlns:asp="#unknown" /> left: 740px; position: absolute; top: 304px" Text="save"/> <asp:panel id="panel" runat="server" xmlns:asp="#unknown">  /asp:Panel> <ajaxtoolkit:modalpopupextender id="MPE" runat="server" targetcontrolid="save1" xmlns:ajaxtoolkit="#unknown"> PopupControlID="panel" DropShadow="true" BackgroundCssClass="modalBackground/> protected void Button4_Click(object sender, EventArgs e) { string id = TextBox1.Text; string name = TextBox2.Text; string cn = "Data Source=hcl;Initial Catalog=mydata;Integrated Security=True"; SqlConnection con = new SqlConnection(cn); SqlCommand cmd = new SqlCommand("insert into customer values (@id,@name)", con); con.Open(); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@id", id); cmd.Parameters.Add("@name",name); cmd.ExecuteNonQuery(); con.Close(); CUSTID.Text = id.ToString(); MPE.Show(); }

saving the data and then deleting the data using javascript function in anchor tag


Hello guys,

What I am trying to do is I have a dataview webpart. In that I have a field called comments which I made it as a text box. I have provided them a option delete. So user before deleting the item, he has to enter the comments and delete. The comments which I enter has to save in list. then I wrote one event handler which is for item deleting, which will copy values to other location deletes the list item.

The problem is the comments are getting saved to list before deleting. The javascript function for delete in anchor tag is 

<a href="javascript: if(DeleteItemConfirmation()) {ddwrt:GenFireServerEvent(concat('_cancel;__delete={',$KeyField,'=',$KeyValue,'};__commit;__redirect=''};

so I have to save the comments before it gets deleted. So I am trying to insert {ddwrt:GenFireServerEvent('__commit;'};this in some place anchor tag before delete, but its getting saved, but not deleting.

Hope you guys understand what I am talking. So can I do something such that it saves the comments and go for delete...

Enable Go Button after entering data in all fields using javascript funtion


Hi friends,

My page is having one gridview with check boxes,two textboxes and one button just like this see this link now i want to enable go button whenever user has select checkbox in gridview and he needs to enter text in two textboxes. i have written onkeyup event for two textboxes to test whether user enter text in textboxes or not but i am unable to write javascript function to check whether user has selected checkbox in gridview or not to enable go button .My requiremnet is user need to enter three inputs select atleast one checkbox in gridview and he needs to enter text in two textboxes.please friends pls tell me how to write javascript function to find whether user has selected the checkbox in gridview or not

search data in xml using javascript



  I have this problem regarding searching within a XML file.
idea is that my search will be based on the keyword entered
in by the user from a HTML form. the keyword is then used to search all
the nodes and the child nodes within a XML file. once the match
is found, i will have to display the results.

But i don't know how to do so - especially the part of searching xml file using javascript

anyone help me in this?

thanks in advance


hide gridview column using javascript. working in ie and firefox but In firefox, gridview data is sh


function EnableDisableGridViewColumn() {
               var AdvanceSearch = document.getElementById('<%= chkboxlist1.ClientID %>');
               var chkList = AdvanceSearch.getElementsByTagName("input");
               var dgTest = document.getElementById("gridview1")
               if (dgTest != null)
                   for (var i = 1; i < dgTest.rows.length; i++) {

                       if (chkList[0].checked == true && chkList[1].checked == true) {
                           dgTest.rows[0].cells[0].style.display = "block";

Retrieving JavaScript data from a post



I'm using the WYSIWYG editor TinyEditor (http://www.leigeber.com/2010/02/javascript-wysiwyg-editor/), and I'm having an issue recalling the updated data. I searched the forum and found someone else had the same issue:


Thing is, I think I've done everything in the post, but my code is just not working. When I click submit, the variable in the code behind (val) isn't capturing any data - Object reference not set to an instance of an object.

Here's my code:

<%@ Page Title="" ValidateRequest="false" Language="C#" MasterPageFile="~/BackOffice.master" AutoEventWireup="true" CodeFile="about-us-club-officials.aspx.cs" Inherits="secure_page_content_about_us_club_officials" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head" Runat="Server">
<asp:Content ID="Content2" Con

SSRS popup page not showing the updated data untill it is refreshed(javascript,asp.net)


i am having a report which shows report data ,once the report item is clicked ,a popup(.aspx) will open theni update the data and close the popup.

issue: when i close the popup i am landing on the parent page but, i have to refresh the page to see the update i did on the popup page.How to resolve this,

thanks in advance

Transmition of data between controler action and javaScript + googleMaps



I can not understand how the views works?

  1. I can not use there asp controls as all the time I have it should be in a control runat server
  2. For what we have so much asp controls to use if we can not use it on view page?
  3. Is any possibility to use in view I dont know something which allow me to use asp controls?
  4. Is something like on view load to call a javaScript function when the view is generating??
  5. I know that my knowledge is not high but I dont know what is different when I have <body onLoad="load()"> and I will have the same function in my view like this:

<%@ Register Assembly="Artem.GoogleMap" Namespace="Artem.Web.UI.Controls" TagPrefix="map" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    All Adventures!
<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server" >
        Travel with Your friends!</h2>
    <table id="main">

how to get dropdown list data VALUE FIELD property in JavaScript



im getting  'ON' as value instead of its actual value

Date and Time Data Types and Functions

The following sections in this topic provide an overview of all Transact-SQL date and time data types and functions. For information and examples that are common to date and time data types and functions

Saving textbox data to MySql database in asp.net


Hi dear coders

though a very simple question to ask, but please tell me how to save and retrieve data in/from my textboxes to/from database (MYSQL) on submit button click.

i know its a very simple task but i cant make it done, so i request you to please send me some working example link or post any helpful code here in asp.net

i will be highly thankful for any kind help from you geniuses.



Excel sheet is not saving data while sending email

Hey Guys,  I am creating a SSIS package, where I am getting all the data into the excelsheet1, which is not formatted. So i created a formated excelsheet2, where i am giving reference to excelsheet1 cells reference. And I am sending email by attaching excelsheet2.              I am having issue when the data is updated, but my email attachment excel is showing old data. When i open the excelsheet1 it is being updated. I don't know why excelsheet2 is not updated automatically. I am using BIDS 2005 . Can anyone please suggest what will solve my problem. Thanks in Advance Priyamvadha

Can you call Javascript function from the codebehind?

 Can you call Javascript function from the codebehind?  How???

saving a text file in ms access data base

i have to read a text file in a text box then have to save it into ms access data base in column format how could i do this....

Why does "reader" in my c# codebehind skip the first row of data when binding to a gridview?


Argh.. I'm making the switch from vb.net to c#, and am just trying to bind some data from a reader in my c # codebehind, but no matter what, the gridview always skips the first row returned from my stored procedure.  What am I doing wrong???

comm.CommandText = "123456";
comm.Parameters.AddWithValue("@SubSectionParentID", SubSectionParentID.Text);

reader = comm.ExecuteReader();

                  while (reader.Read())
            gvMenu.DataSource = reader;


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend