Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Ajax Toolkit to JQuery

Posted on 2014-10-21
6
Medium Priority
?
242 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
  • 3
  • 2
6 Comments
 
LVL 61

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 61

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 61

Expert Comment

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The viewer will learn how to dynamically set the form action using jQuery.
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
Course of the Month11 days, 15 hours left to enroll

564 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