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

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

How to pass javascript array to ASPX

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net


     I was trying to pass the js' array to webservice, but it failed. The error generated by the framework is "new Web.Net.MethodRequestError(\"Object of type \'System.Object[]\' cannot be converted to type \'User[]\'.\",\" ".
    Can anybody help me? thx a lot

clientside code
     function User(name,age)
        this.Age = age;
        this.name = name;

      function onbtnclick()
        var child = new User();
        child.Name = "congling";
        child.Age = 1;
        var user = new User();
        user.Name = "congling";
        user.Age = 1;
        user.Sons = new Array();
        user.Sons[1] = child;

View Complete Post

More Related Resource Links

>>>How to use javascript function in aspx file?



I have a file util.js and there some funtions in same file.

For example functions name are keyUp, keyDown, isNumeric, isAlphaNumeric

I have used these functions in aspx code behind in a textbox to restrict user that he may not be able to input any special character.

Before, I used the code directly in aspx file but I have do it for different textboxes therefore to avoid much coding in aspx file I created util.js and put all code in this file but how to use these particular functions in aspx file I couldn't find the way.

Anyone have idea. Do share with me.

I used the reference like this:


' Font-Names="Verdana" Font-Size="8pt" Onkeyup= "keyUp(event.keyCode)" Onkeydown="return isAlphaNumeric(event.keyCode);" onpaste="return false;">

How to Pass higher Length of Byte Array to the remoting method

Dear all,I am using a windows application and the businness logic is present in the remote server.Once particular method takes bytearray as input parameter...Whenever the method call is made the function returns value .This is limited for the particular bytearray length. (4109228 bytes).If the length of bytearray crosses 4109228 bytes.I am getting an error that "input stream is not valid binary format".How to Pass higher Length of Byte Array to the remoting method... Greater than 4 MB?I believe something is missing in web.config or app.config...?What could be the issue...? Any sugesstions are welcome....ThanksRavikumar

Javascript to pass var in iframe to parent form

Why doesn't this form work when the button is clicked? It is inside an iframe. I sent the controls to an iframe from  a different website. When I hover my mouse over the Resubmit button, I can see the correct url in my browser bar. (lower left) This is the same one as the save button. Does the fact that the Resbmit button is in an iframe create a problem?  Is this a security issue?   I was trying to use the Copy url to clipboard button to copy the selected url in the dropdown to the clipboard. Then the user could paste it into the Recipcocal url field in the form and click the Save button again. (see picture) The form is on the page with the iframe. The copy button doesn't work either.  <form name="ctl01" method="post" action="http://www.link-exchangers.com/adv_links_addbycustomer.aspx" id="ctl01" target="hdnFrm"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUaUXIyTcD6f05q0zIbv4QVbpto4s=" /> </div> <div> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="//2DwKU+M6MDwK8m8+dCQKy8rjSBwLD+aWMBALcwYfHCALrp+eHDwKggI3ODAKvtqqBBgKjs8y4CAKqiLHeDgK34agCBNfAteTeI3XoiXVXjCs/J0yEnNM=" /> </div>

Javascript at the end of aspx files. What is the benefit?

Hello,In one of the examples I saw a call to a JS function at the end of the aspx file.Like the following:<script language="javascript" type="text/javascript">   <!--    SetExternal();   // --></script>I was under the impression that the JS functions are either called on onlclick of button events or in the HTML Body tag with Onload.So when an aspx page loads then do you thin the following function which is at the end of the page will be called? and why do we put these functions at the end of the page?Thanks.

calling a javascript function within aspx

i have a js method i wrote myself called sumAlert();  i want to call it in my aspx like this, when a user clicks on a button<asp:Button ID="Button" runat="server" Text="Submit" OnClientClick="if (confirm('WARNING! You will be unable to save again if you proceed')) sumAlert();"                        OnClick="Button_Click" />How can i get it to call the function if the user confirms OK?

modify/override properties of default sharepoint modal dialogs (ex. editview.aspx) using javascript

Hello all, I would like to know how can I modify (override) some properties of the default sharepoint modal dialogs using Javascript. Ex. the size and location of editview.aspx. I while ago I asked a question about overriding the DialogResult in the display view dialog. I got an answer from Zach which looked like this:             sb.Append("<script type=\"text/javascript\">");             sb.Append(@"window.setTimeout(function () {");             sb.Append(@"if (window.frameElement && typeof(window.frameElement.overrideDialogResult) == 'function')");             sb.Append(@"{");             sb.Append(@"SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.DialogResult.OK', function () {");             sb.Append(@"window.frameElement.overrideDialogResult(SP.UI.DialogResult.OK); ");             sb.Append(@"});");             sb.Append(@"}");  

pass number of rows of Gridview to a javascript function

using vb.net/asp.net 2005.I need to pass the number of rows of the Gridview to a javascript function does anyone know how to do this?  thanks

Access Javascript from an aspx file through another aspx file

Hello, So.. I have a file called myFile.aspx which is linked to a js file called myJS.js    There is a file linked to an entirely different frame called theOtherFile.aspx.  I want to access a function is myJS.js called myFunc in theOtherFile.aspxI am not entirely sure how I would accomplish that..I am quite new to MVC2 and JS, so I am quite confused as to how to do this.  Any suggestions would be much appreciated.~Anath

How to use GZIP for aspx, css, and javascript files.

Hi all,I have heard that if we use gzip, aspx files will be loading faster. But, I am not sure as to how to use it in my web applications.I am hosting my site with GODADDY (ASP 2, IIS 7)Can anyone tell me if I will be able to use gzip? Can you give me a sample file where gzip is used?Thanking you in advanceTomy

Passing an array to Javascript function, and SetTimeout

Hi, I have a js function that takes an array (of strings) as a parameter. I read some data from DB and create the a parameter and pass it to js function but it only sees the first entry. Here is the sample ( i cut out unnecessary stuff):var singletext = new array();function ns6scroll(singletext) { setTimeout("ns6scroll(" + singletext + ")", spause); } In code behind: string[] saAlerts = new string[lsAlerts.Count]; int i = 0; foreach (DMSAlertDO oAlert in lsAlerts) { StringBuilder sbAlert = new StringBuilder(); sbAlert.Append("'<nobr align=\"center\">"); if (oAlert.NavigateUrl != string.Empty) sbAlert.Append("<a target=\"_blank\" class=\"scroller\" href=\"" + oAlert.NavigateUrl + "\">" + oAlert.AlertText + "</a></nobr>'"); else sbAlert.AppendFormat("{0}</nobr>'", oAlert.AlertText); saAlerts[i++] = sbAlert.ToString(); } if (!ClientScript.IsStartupScriptRegistered("StartScroller")) { StringBuilder sbScript = new StringBuilder(); sbScript.AppendFormat("<scr

Pass values between user controls on 2 different aspx pages

I have 2 user controls that is hosted by 2 different aspx pages.example: srcpage.aspx --> hosts the --> sourceusercontrol.ascxanddestpage.aspx --> hosts the --> destinationusercontrol.ascxI would like the values in the text fields of the sourceusercontrol.ascx to be passed on to the labels in the destinationusercontrol.ascx. I have gone through the MSDN ASP.Net examples and i was able to successfully pass values between two aspx page using the postback URL functionality, but cannot do the same thing with the usercontrols on 2 different aspx pages. Any suggestions would be helpfull....! Thanks..! 

Converting a Javascript/SQL array for use in asp.net VB

Hi all:   Thank you all in advance for your patience with me on this one!  This will be my first attempt at understanding code-behind. I have a JavaScript banner marquee that I am currently using in an ASP classic site.  I feed the script with banner info from a SQL array and the script runs the banners in a loop.  I want to use this on my ASP.net site conversion (from ASP classic) but I don't even know how to begin.  I have read some books, did the tutorials, but I will still need some help getting off the ground on this. Here is the ASP code.  I don;t care about the tables, rows, etc as that will be converted to CSS.  I just really need to know how to handle the array to feed the script.  Also, I am working in VB.net. I did not include the actual Javasrcipt either...  <% Set RS = Server.CreateObject("ADODB.Recordset") SQL = "SELECT xlaABMiBannersZones.bannerID, bannerfile, link FROM (xlaABMbanners INNER JOIN xlaABMiBannersZones ON xlaABMbanners.bannerid = xlaABMiBannersZones.bannerid) WHERE zoneid = '18' AND enddate >= GetDate()-1 ORDER BY enddate" set RS = conn.execute(SQL) Dim arrMini If RS.BOF AND RS.EOF Then RS.close set RS = nothing Else arrMini = RS.GetRows() End If RS.close set RS = nothing %> <div id="marqueecontainer" onmouseover="copyspeed=pausespe

Can't pass string to javascript function(unterminated string)

Hello,I have a problem. I can't pass string like this  ": Mar 15 2004 12:00AM  Refnr: 20040315!m>N0"to javascript function because I have symbols like these >, <, % ?tc.Situation:I have a Grid and I have column with DataItemTemplate,Within my dataitemtemplate I have <a href="javascript:void(0);"  onclick="ShowAccountStatementNote(document.getElementById('<%= lblHiddenNoteText.ClientID %>').value);" >                                                          Bekijken...                                                      </a><a href="javascript:void(0);"  onclick="ShowNote('<%# EncodeStringToHTML(Eval("Note")) %>');" > Notes </a>ShowNote function just show popup with text = NoteEncodeStringToHTML do Server.HtmlEncode(); But It doesn't help because even if we change text on server .... e.g. "dfdf%" convert to "dfdf&#37;"  anyway on client it becomes again "dfdf%" and problem still exists.On clien

Adding JavaScript to Default.aspx


Hi there,

I am relatively new to SharePoint Designer and want to add a piece of JavaScript code that I have used before on standard HTML websites but I am not 100% sure where to put the code on the page.

I tried already and got an error so I have removed the code and the page works as standard.

Below is the code I inserted to a webpartzone (right) replacing the &nbsp; which was already there.

<script type="text/javascript">
//new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay, pause (0=no, 1=yes), optionalRandomOrder)
new fadeshow(fadeimages, 300, 220, 0, 7000, 1)

The main script is very long so I hadnt pasted it in but i placed it at the top of the page (when in code view). Here it is below:

What am i doing wrong?

The Commish

<script type="text/javascript"> 
* Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["images/rotate01.jpg", "", "

Capture query string value in javascript in aspx page


I have a simple problem that I cannot remember how to solve.  I am sure it is very easy.  Following is my code:

<asp:Image id="btnAddNew" runat="server" ImageUrl="~/images/btnAdd.png" OnClick="javascript:window.open('DetailLocation.aspx?projectID=&locationID=','newWindow','width=600,height=600,scrollbars=yes');" />

In the OnClick event I have embeded a javascript function that works as expected. However, I need to embed a querystring value into the javascript function variable:


I thought I could just embed <%=Request("projectID") %> in there, but the compiler does not like it. 

Thanks in Advance.



Pass string to Javascript function from code-behind...



I'm trying to send a error message to a javascript function from code-behind, but it's not working. When the javascript is executed the output error is: [object Object]

Here's my Javascript:

function Error(error) 
            document.getElementById("<%= errorText.ClientID %>").innerText = error;

And my C#:

        textError = "This is not working!!!";

        ScriptManager.RegisterStartupScript(Page, this.GetType(), "Error", "javascript:Error('" + textError + "');", true);                

Even if i pass the string instead of the 'textError' variable i still get the same error :(

Can anyone help me?

problem in passing string array from activex dll to JavaScript


I do have a problem in passing string array from activex dll to JavaScript. i need to implement a methos as 

C# : 

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