?
Solved

Ajax Toolkit to JQuery

Posted on 2014-10-21
6
Medium Priority
?
236 Views
Last Modified: 2014-10-22
I have been trying to convert scripts that I have in AJax Toolkit to JQuery. How to I get the spinner to read values from a database? Below is how I set it up the NumericUpDownExtender in Toolkit but I am at a loss on how to use spinner to read values from a database

        public void TimeList()
        {
            SqlConnection conn;
            SqlCommand comm;
            SqlDataReader reader;
            string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            conn = new SqlConnection(connectionString);
            comm = new SqlCommand("SELECT FollowupTime FROM S_Setup", conn);
            try
            {
                conn.Open();
                reader = comm.ExecuteReader();
                if (reader.Read())
                {
                    string Followup = reader["FollowupTime"].ToString();
                    NumericUpDownExtender1.Minimum = Convert.ToDouble(Followup);
                    NumericUpDownExtender1.Step = Convert.ToDouble(Followup);
                }    
                reader.Close();
            }
            finally
            {
                conn.Close();
            }
        }

Open in new window

0
Comment
Question by:RecipeDan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 40397000
This question has moved into the neglected category - so will attempt to help but not familiar with the .Net tech you are using.

You might need to post some more code.

Show us where you are trying to make the AJAX call

The code you have posted does not seem to return anything that would be useful to an AJAX call
0
 
LVL 1

Author Comment

by:RecipeDan
ID: 40397437
Hello:

Why was it moved to the neglected category? I only asked the question last night. Maybe I was not clear.

I am converting AJAX Toolkit Scripts to JQuery. One of the scripts that I am converting is the AJax Toolkit NumericUpDownExtender. The way my script is now, the NumericUpDownExtender is dynamic and reads values from a database. So what I want to do is use the JQuery Spinner instead of the AJAX Toolkit NumericUpDownExtender.

What I do not know how to do is get the values from a database and put them in the JQuery Spinner Code so that the Step Value and Spinner value are dynamic based on user input. Below is my JQuery Spinner Code

  <script>
  $(function() {
    var spinner = $( "#spinner" ).spinner();
     $( "#spinner" ).spinner({
      step: 5,
      numberFormat: "n"
    });

    $( "#setvalue" ).click(function() {
      spinner.spinner( "value", 15 );
    });
  });
  </script>

Open in new window

0
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 40397614
Look at create or start event for Spinner.

http://api.jqueryui.com/spinner/

Perform, ajax call to server
Assign the returned result to set min and max limits
e.g.

$('#spinId').spinner('option', 'min', data.min);
$('#spinId').spinner('option', 'max', data.max);
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 58

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 40397701
@recipedan
Why was it moved to the neglected category? I only asked the question last night
This is an automatic process that kicks in if a question does not receive any responses within a certain time period - it is meant as nudge for experts to come and take a look.

In terms of what you want to do there are several options. If you are rendering out the Javascript as part of your page render you can simply put the retrieved values into the JQuery code with <%=DB.Value%>

Failing that you can output var statements from your code
var step=<%=stepValue%>;
var initialValue = <%=initialValue%>;

You can then modify your code to use these variables.

A third option is to embed values into your #spinner element as HTML5 data elements
[code]<input id="spinner" type="text" data-step="5" data-value="15" />

Open in new window

And then use JQuery like this.
  <script>
  $(function() {
  
    var spinner = $( "#spinner" ).spinner();
     $( "#spinner" ).spinner({
      step: $('#spinner').data('step'),
      numberFormat: "n"
    });

    $( "#setvalue" ).click(function() {
      spinner.spinner( "value", $('#spinner').data('value') );
    });
  });
  </script>

Open in new window

0
 
LVL 1

Author Comment

by:RecipeDan
ID: 40398503
Awesome.Thank you
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 40398590
You are welcome - thanks for the points and good luck with your project.
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question