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


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

* Read/connect my "DBConnectionString" from webconfig in JavaScript

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net
 

Hi,

Any one send me sample code, 

I have my ASPX.net + SQL 2008

I have "DBConnectionString" in my webconfig.

I want read/connect my "DBConnectionString" from webconfig, how to do that... ?

 

function getSubmit() {
		        var txtDivOpen;
		        var cn = new ActiveXObject("ADODB.Connection");
		     
		        var strConn = '<%=ConfigurationManager.AppSettings["DBConnectionString"].ToString() %>';
		        var rs = new ActiveXObject("ADODB.Recordset");
		         
		        var SQL = "select * from ENVDB_WASTE_COLLECTION";

		        cn.Open(strConn);
		        rs.Open(SQL, cn);
		        rs.MoveFirst;

		        document.getElementById("ListBox1").options.add(rs.fields(1));

 
		        rs.Close();
		        cn.Close();
		    }




View Complete Post


More Related Resource Links

read cookie in javascript

  

Hi i have set a cookie in c# code and made sure the HttpOnly = false, i need to read this in javascript but need some help.

i am trying the following...


//c# code
HttpCookie cookie = new HttpCookie("CompId", item.Id.ToString());
cookie.Expires = DateTime.Now.AddHours(1);
cookie.HttpOnly = false;
Response.Cookies.Add(cookie);

//js code

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function Test() {
var compId = getCookie('CompId');
     

Read Excel file to datatable using javascript

  

I have an asp.net website. I have to upload data from an excel file on the client machine to sql server. I save the excel file on the server where webstie is hosted and try to read from that excel. But users dont have read permission on the server. So i need to read the excel on the client side using javascript and populate the datatable so that i can use that datatable in sql bulk copy to populate my sql tables. so how to read entire excel in javascript and populate to datatable


read and print sharepoint list information using javascript

  

hi,

i am working on a form right now, user's inputs will be stored in a sharepoint list. after user click submit, it will display a thankyou panel, and send a email to me showing user's input. on the thankyou panel, there is a button, if user click it, it will open a new window and display exactly the same thing in email, so that user can check if they input the right thing.

i did this part using javascript, the window.open method. and i wrote html code in it, using window.document.write method.

i wrote a read from sharepoint list function, i dont know if it is working, but my question is how can i call this function in javascript since it will be a client side programming.

my readfromlist code is here:

public void readFromList()
         {
             SPSite oSiteCollection = SPContext.Current.Site;
             SPList oList = oSiteCollection.AllWebs["something"].Lists["somelist"];
             SPView oListView = oList.Views["All Items"];
             SPListItemCollection collectListItems = oList.GetItems(oListView);

             foreach (SPListItem oListItem in collectListItems)
             {
                
                 txtFirstName.Text = SPEncode.HtmlEncode(oListItem["First Name"].ToString()) + "<BR>";
             

Javascript issue - read from xml

  

I'd like to read data from my xml, but I always get a nasty "xmlDoc.getElementsByTagName(...).0' is null or not an object" error

I can make an alert with an entire xml, but the problem is i can't read it!?


Here is my JS code:


 <script type="text/javascript">
        function parseCommentXmlToHtml(xml, motivatorIndex) {

            function loadXMLString(xml) {
                if (window.DOMParser) {
                    parser = new DOMParser();
                    xmlDoc = parser.parseFromString(txt, "text/xml");
                }
                else // Internet Explorer
                {
                    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                    xmlDoc.async = "false";
                    xmlDoc.loadXML(xml);
                    alert(xmlDoc.getElementsByTagName("images")[0].getAttribute("author_nick")); // ERROR
                }
                return xmlDoc;
               
            }

            loadXMLString(xml);

          
        }
    </script>

Here is my XML:

<root>

<images insert_date="2010-10-10T20:06:00" comment_text="afs" author_nick="Guest"/>

<images insert_date=&

HyperLinkField Javascript DispEx: clicking link shows Read Only/Edit dialog

  

I have a web part that uses an SPGridView to display the documents that match previously selected criteria.

The user needs to see the 'Read Only / Edit' dialog that is displayed when a document is selected directly from the document library.

My research shows that I need to call the Javascript DispEx function somehow. How do I do this in the HyperLinkField setup? Can I somehow call it in the DataNavigateURLFormatString? This code is my latest attempt (which doesn't work). The 'onclick=' appears in the hyperlink.

 Dim hfTitle As New HyperLinkField()
            hfTitle.DataTextField = "name"
            hfTitle.DataNavigateUrlFields = URL
            hfTitle.DataNavigateUrlFormatString = _
"<a onclick=" & Chr(34) & "return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.2','0','SharePoint.OpenDocuments','','','','1','1','0','0x7fffffffffffffff')" & _
Chr(34) & "href={0}"

            hfTitle.HeaderText = "Name"
            hfTi

how to connect webservice from javascript in asp.net

  

i want to connect webservice from javascript and pass the parameters.help me





Thanks




Unit Testing Error - The unit test adapter failed to connect to the data source or to read the data

  

I'm using VSTS 2K8 and I've set up a Unit Test Project. In it, I have a test class with a method that does a simple assertion. I'm using an Excel 2007 spreadsheet as my data source.

My test method looks like this:

        [DataSource("System.Data.Odbc",  
       
"Dsn=Excel Files;dbq=|DataDirectory|\\MyTestData.xlsx;defaultdir=C:\\TestData;driverid=1046;maxbuffersize=2048;pagetimeout=5",
 
       
"Sheet1",
 
       
DataAccessMethod.Sequential)]
 
   
[DeploymentItem("MyTestData.xlsx")]
 
   
[TestMethod()]
 
   
public void State_Value_Is_Set()
 
&nbs

ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

  
This post covers another useful improvement in VS 2010 - HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of "snippets" for VB and C# in previous releases - but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

Ajax Enabled Gridview using JavaScript in ASP.NET

  
Before explaining the article, I would like to thank all readers who read my article and voted for it. Your appreciation for my article gives me strength to write more good articles. Hope in future I will get your valuable comments and suggestions. Now I won't waste your time and come back to the topic. I have written this article on 'Ajax Enabled Gridview Using JavaScript in ASP.NET'. In this article, I will show you how to make a Gridview using a simple HTML table, JavaScript and XML HTTP for Ajax call without using any ASP.NET control.

Using Code

GridView Javascript Click Row and Ajax

  
This article shows 2 common tasks with the ASP.NET GridView: Binding a List (generic) of objects as DataSource and on clicking a row, getting the values of the selected row by a javascript function. In the example a List with User-objects is displayed. On clicking a row containing the data of a User-object, the Id of the object is used to get the address of the user by an Ajax-call and display it in a details-field.

InfoPath 2010 cannot connect to SharePoint 2010

  
You have installed Office 2010 beta and you are trying to connect to SharePoint 2010 from InfoPath but you get an error

Combine, minify and compress JavaScript files to load ASP.NET pages faster

  
Websites are getting more interactive these days and most of this interactivity comes from JavaScript. People are using different JavaScript libraries and frameworks to make their websites more interactive and user friendly.

Serial Port Communication Read and Write using C#.net

  
In this simple article you will learn that how you can Open and read COM port data using System.IO.Ports Namespace.
Simply just create New Project of windows application in C#.

Import ServiceProcess APIs
C#:
---
using System.IO.Ports

VB
Imports System.IO.Ports

Write Parsing functions which parse port data according to attached device

how to impose javascript event processing?

  

If I have some form control like textbox and I want the event handler to be located in the html instead of at the server side, how to do that? Of course I can copy paste javascript code in the aspx file. But is it possible to do that using some object oriented approach (ie programmatically in the code behind)?

Thanks


Categories: 
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