Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:46:41+00:00 2026-06-17T10:46:41+00:00

I have a simple site with just 1 page that has a form with

  • 0

I have a simple site with just 1 page that has a form with just 1 field and a submit button.

It asks for a phone number and calls a stored procedure with the value of the phone number captured in the form. Once submitted, it feedbacks the user saying that the number was submited, and it stays on the page so the user can enter another phone number.

So I created a cshtml file that looks like this:

@{
string pn=Request.Form["pn"]
and then my code to call the stored procedure with pn as a parameter
}

The problem I am having is that when I go to this page the server side throws an error saying that the stored proc expects a parameter that was not supplied.

Therefore, I want to create a JavaScript function that will run onload of the page that will only call the stored proc if pn has a value.

How do I do that, and where should I place the code (JS inside the @{} block?)

BTW, as of now, I have 2 pages. The first one, without any server side code, and the second one which is a copy, plus the server side code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:46:42+00:00Added an answer on June 17, 2026 at 10:46 am

    In the first place you don’t need a JavaScript function to validate your input client side, but a server side code to test if the form is submitted and if there is a valid value into your field.

    Something like:

    @{
        if (IsPost)
        {
            string pn=Request.Form["pn"];
            if (!string.IsNullOrEmpty(pn)){
                /* your code to call the stored procedure */
            }
        }
    }
    

    If you want to deepen this subject, look at this tutorial: Introduction to Working with a Database in ASP.NET Web Pages (Razor) Sites.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting familiar with Codeigniter (2.1.0) and building a simple site, that has
I have an ASP site that has the simple job of storing and retrieving
I have a page in a site that contains an iframe with a form
I'm creating a simple site that has menu and a submenu. When the page
I have a pretty simple site, which has a footer that is stuck to
I have a simple web site ( http://www.kousenit.com/twitterfollowervalue ) that computes a quantity based
Lets say I have a simple ecommerce site that sells 100 different t-shirt designs.
I have a very simple sinatra site that I'm trying to access via ajax
I have a very simple MVC site that is returning a 404 not found
I have a simple form at my site which sends it data via Ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.