.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

Calling Javascript from loop inside a Sub

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
Hi Guys, I had a copyfile sub that worked fine on my local testing environment in VWD 2008, but now that it is on the server does not work. I assume it is because it is looking on the server for the files, not the local client machine. I am now trying to use client side Javascript to mimic the process. I have created a JS function to do it, but I can't get it to call the JS function inside my VB Sub. Here's the code, thanks to all replyers in advance! Public Function Copy_Photo(ByVal path_in As String, ByVal newname As String) As String Try Dim ret_path As String = Me.Master.get_mug_shot_folder ret_path += newname Response.write("<script type = 'text/javascript'>CopyPhoto('" & path_in & "','" & ret_path & "');</script>") Return ret_path Catch ex As Exception msg_div.InnerText = "ERROR: Could not properly copy file " & path_in & " to location " End Try End Function    Notice how I tried using the Response.write method. It gives me an Object Required error everytime. Here's the JS function: function CopyPhoto(oldFile, newfile) { alert(oldfile + " " + newfile); var fso; fso = new ActiveXObject("Scr

View Complete Post

More Related Resource Links

calling JavaScript from inside TabPanel


I had a standard ASP.NET page where I had a some client side Java script make some controls visible/enabled if a checkbox was clicked or not.


<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script language="javascript" type="text/javascript" >
        function Email2Checkbox() {
            var checkbox = document.getElementById("<%=cbEmail2.ClientID %>");

            if (checkbox.checked == true) {
                document.getElementById("<%=lblEmail1.ClientID%>").disabled = false;
                document.getElementById("<%=dropEmailType_2.ClientID%>").disabled = false;
                document.getElementById("<%=lblEmail2.ClientID%>").disabled = false;
                document.getElementById("<%=txtEmail_2.ClientID%>").disabled = false;
                document.getElementById("<%=regexValEmail_2.ClientID%>").disabled = false;
            else {
                document.getElementById("<%=lblEmail1.ClientID%>").disabled = true;
                document.getElementById("<%=dropEmailType_2.ClientID%>").disabled = true;

way of calling "javascript function of parent window from child window."

The article way of calling "javascript function of parent window from child window." was added by raja.s on Sunday, June 06, 2010.

Hi,Here i am going to explain how to call the javascript function of a parent window from the child window(pop-Up).Some may know before reading this post.Parent Java Script Function:script language="Javascript" type="text/javascript">

dsqueryresponse inside a Javascript Block


I use <xsl:value-of select="/dsqueryresponse/Rows/row/@whatever"/> to get information about the current item I am in. ID numbers, row info, etc..

I need to get this same information but inside a javascript block, how can I do this?



Example of calling AuthenticationService from javascript ...??


I have a plain html page (no asp.net form) and want to login (wcf rest,  json) via this form. I created an Authentication.svc, modified my web.config and try to authenticate via javascript. When running my page and trying to login I get a 500 error. Please find my code snippet hereunder. Can someone please give me a clue as what I'm doing wrong? Thanks.



 // Define global variables.       
        var username;
        var password;
        function pageLoad() {
            username = $get("txtUser");
            password = $get("txtPassword");
            buttonLogin = $get("ButtonLogin");
            buttonLogout = $get("ButtonLogout");

how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

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?

InvalidCastException when calling JavaScript from C# control using a second thread.

Original Issue: I need to be able to call functions in the JavaScript of an HTML page (not ASP.NET) from a C# object embedded in that page.  The c# object has to be .NET 2 level. So I created a C# DLL assembly in VS 2010 which contains a class called NoUIControlClass. set the target framework to .NET 2.0 and made sure to check "Make assembly COM-Visible".  I also signed the assembly so it would have a strong name so I could install it in the GAC.  So far so good. Here is the batch file I run after the project is built to register the control and place it into the GAC: copy "C:\Users\x\Documents\Visual Studio 2010\Projects\NoUIControl\NoUIControl\bin\Debug\NoUIControl.dll" C:\Exploration\NoUIControl C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm NoUIControl.dll /unregister C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm NoUIControl.dll NoUIControl.dll C:\"Program Files (x86)"\"Microsoft SDKs"\Windows\v7.0A\Bin\gacutil.exe /u NoUIControl.dll C:\"Program Files (x86)"\"Microsoft SDKs"\Windows\v7.0A\Bin\gacutil.exe /i NoUIControl.dll This works and all is good.  Next I've turned the security level in IE all the way down for intranet and trusted sites.  Just to make sure that doesn't get in the way.  Here is the HTML file I serve from the web server. <html> <head

Viewstate issue when calling button click event from Javascript

I have a javascript that asks a confirmation on search click. If the user has made some changes to the data in grid (gridview) on click of Search, a confirmation is asked to Save or Continue Search. If Yes, Save the records by invoking Save click from javascript. If No, Search click is invoked. While Search click happens correctly, Save click results in an error which reads like this..  "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. " I know the Viewstate is what causing the problem, where the control is not loaded but script is trying to invoke it's click event. Any help is appreciated. At the end of the day, all i need is to invoke Save click from javascript.   -- Viswanth VG  

Validating DropdownList Inside Gridview Using Javascript

hi All,      I have Gridview with Dropdownlist which contains data as {select,1,2,3} .Gridview contains multiple rows of data.Submit button is also on form but outside gridview. If any of the rows of gridview dropdownlist contain value as "Select" and click Submit button ,give message as "Please select value". I want to do this stuff using javascript. Thanks in advance.

Create task activity break out inside a While loop

Hi I have developed a sharepoint state machine workflow. I want to assign a same task to more than one users, but unfortunatly, I cannot give the attribute "AssignTo" to more users in the code, even like this:"this.workflowTask1Properties.AssignedTo = "mydomain\\user01;mydoman\\user02", that will result in an empty value to the attribure.So, I involved the createtask activity in a While loop so I can asign deferent user in each loop, but It's very stange,  the loop always stopped in the second time, does anybody have met this issue?I have referensed Amit's question:http://social.msdn.microsoft.com/forums/en-US/windowsworkflowfoundation/thread/b238978d-f330-420c-823e-b77b0e19414d?prof=requiredbut I have no define the "correlation refernce " in my workflow.my code is here:public SPWorkflowTaskProperties workflowTask1Properties;public int abc;...private void OnWorkflowActivated(object sender, ExternalDataEventArgs e)        {            ...           this.abc = 0;           ...        }...private void CreateTask1(object sender, EventArgs e)        { 

Calling csharp code from Javascript

Hi, Is it possible to call a c# code block from Javascript in Sharepoint 2010? I am using redirects to pages at the moment to achieve the effect, but the results are far from desirable. Any help would be much appreciated.   Cheers, M

SSIS For Each loop with data flow hangs on DTC (SID -2) when inside transaction

The short story: I have a data flow inside a For Each container that is inside a sequence container.  A transaction is established at the sequence container, with Isolation Level Serializable.  The For Each container is limited to execute only 4 iterations.  The data flow iterates once fine, but the second iteration hangs.  The Activity Monitor shows the process is waiting on a another process with a SID of -2.  From other research in the past, I have found that this is an internal process dedicated to DTC (Distributed Transaction Coordinator). Environment: Microsoft SQL Server 2005 (SP3) on Windows 2008 R2 Standard.  I'm using SQL Server BIDS 2005 for building these packages.  I also have SQL Server 2008 installed and the databases are installed there. The details: The data flow merges data from the same table in two databases, source and target, using a Merge Join component.  It then performs a few transformations and lookups from other tables in the target DB to get IDs.  Then it inserts new records into the target DB or updates existing records in the target DB.  The two source tables are using OLE DB Source components with customized queries.  The insert target component is an OLE DB Destination and the update target component is an OLE DB Command.  In this particular scenario,

How can we show and hide iframes progarmmtically in javascript, calling the function from a seprate

I have currently placed 5 iframes inside 5 divs and i m trying to show and hide iframes by following code if (docid == idpath_array[1])             {                document.all("div1").style.display = 'block';                document.all("div2").style.display = 'none';                document.all("div3").style.display = 'none';                document.all("div4").style.display = 'none';                document.all("div5").style.display = 'none';            } but the problem is that after setting style of one div as display:none,I am not able to display the same div latter by setting display:block hence programmically I am not able to display an already hidden iframe by making display:block in div

Calling a Server side function from Javascript without using PageMethods

Good Day alli have used PageMethods to access the server side functions in javascript , but now my problem is that with pagemethods your controls will not go throught the full page lifecyle and these leads me to have "Object not set for an instance of an object" error. Now can someone come with a differnt approach without using pagemethods. What i want is to call a server side function , i dont want to pass any parameters to itthanks

Checking the calling of JavaScript Code?


Hi Experts.

I am looking for the way to solve my problem. Suppose the following scenario:

You have a simple JavaScript code to connect with server and return some parameters form server and use it in your webpage. Like:

<script language="JavaScript">id=100</script> 

<script language="JavaScript" src="">           

The content of samplecode.js is like this:


                // code here.



When the script is run, some parameters are returned from server and is write into your page. Like: (document.write(parameters) ).

So now You want to use this script more than one time in your webpage. Then each time  is run separately and the parameters are returned in separately call. Like:

<script language="JavaScript">id=101</script> 

<script language="JavaScript" src="">

When the first JavaScript is called,  How can return the all parameters that is returned in separately JavaScript? Or Is there any the way to check to several times the javaScript is called in the page and when jus

JavaScript Error while calling a drill through report in a report viewer from a asp.net web page.


I am calling a report in a web page which is getting displayed in report viewer. This report comes fine but when I click on it to see the drill through report for this parent report the drill through report does not get displayed and I see a JScript error instead.

The error I get is something like,

parent.document.GetElementByID(...).ClientController is not null or not an object

The aspx page that contains the report viewer inherits from a master page that contains an Update Panel.

I tested the report separately in SSRS and the drill through is working fine there.

Can some one please provide any inputs on this one?



Referring Control inside datalist from javascript


Hi All,

Problem i am facing in referring textbox control in javascript which is inside Datalist control . i havent found any right solution for the problem if anyone can contribute then i will be very thankfull.

<cc1:lecklabel id="lblnpc" runat="server" token="0" Width="942px" BackColor="SteelBlue" Font-Bold="True" ForeColor="White">Non Production Cost System</cc1<

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