Solved

Ajax Toolkit to JQuery

Posted on 2014-10-21
6
225 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 51

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 28

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 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 51

Expert Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
The viewer will learn how to dynamically set the form action using jQuery.
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)

757 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now