Results 1 to 9 of 9

Thread: asp.net page not returning any results, no msgbox() when clicked extra..

  1. #1
    New Member
    Join Date
    Feb 12
    Posts
    9

    asp.net page not returning any results, no msgbox() when clicked extra..

    Hi guys any ideas on this, I am trying to get my first asp.net app running.
    If I click a button it just refreshes the page returning nothing any ideas what might be causing this?

    Thanks.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 12
    Posts
    5,982

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    Sorry, my crystal ball is a bit foggy at the moment! You wanna give us a clue or shall we just assume that the answer is there's no code for the button?

  3. #3
    New Member
    Join Date
    Feb 12
    Posts
    9

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    haha ill give you another clue, there is no database involved just a few txt boxes, a button, the idea is you enter some numbers hit the button and it spiffs out the answer into the txt control pretty simple but nothing it just reloads the page numbers are still there but no answer I stuffed around with the config file for a bit but I don't think that is causing it so I don't know what to do next, i didn't know deploying asp.net from visual studio could be such a bugger and by the way it does work of course locally just not when it's uploaded to the webserver
    Last edited by moto485; Aug 8th, 2012 at 05:23 PM.

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,838

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    Hello,

    In the title of this post, you mention MsgBox(), which leads me to suspect that you are actually using one. Would it be possible to show the code that you are using just to confirm?

    If you are using MsgBox(), then as you have seen, when debugging out of Visual Studio, this will work perfectly, this is because your development machine is acting as both the web server, and the client. However, when you deploy to an actual web server, and access it from a "remote" client, you will definitely NOT see the MsgBox(). The MsgBox class lives in the System.Windows.Forms namespace, and as such, can only work on the machine that is actually running the code, it doesn't send the necessary HTML/JavaScript down to the client machine to make the MsgBox appear on the client.

    Does that make sense?

    The use of the MsgBox class within an ASP.NET application is definitely not recommended. You would be better off using using like a JavaScript alert box, or using a custom HTML DIV that you can toggle the visibility on to make it appear like a MsgBox.

    Hope that helps!

    Thanks

    Gary

  5. #5
    New Member
    Join Date
    Feb 12
    Posts
    9

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    That makes perfect sense thanks for taking the time to explain that to me Garry, I didn't even think about that.
    I do apologise for using the msgbox() as an example I am actually not using it. I was not getting any response from the form so I just add a message box in the hope it would respond.

    Basically I don't know much about asp. I moved my from Linux to Windows server just the other day so I could play around with asp.net and thought I would do a quick form just to get a practical sense of how asp.net is deployed before I started on customer management system for work.

    Take a look http://www.tymax.com.au/LED you can see it was very quickly put together, the button on the left calculates it all the button on the right is the msgbox() I threw in, the two "Annual" buttons are supposed to be show the results when you click the left mouse button.

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,838

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    Hey,

    Without seeing some of the code that you are using, it is going to be difficult to help out further.

    Are you able to post the code that you are using?

    Gary

  7. #7
    New Member
    Join Date
    Feb 12
    Posts
    9

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    So not sure which code you need to look at just let me know what you need.

    This is the default.aspx page:


    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" enableViewStateMac="false" enableEventValidation="false"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div align="center" style="margin-top:40px;">

    Light Wattage
    <asp:TextBox ID="TextBox1" runat="server" Width="38px"></asp:TextBox>
    &nbsp; QTY
    <asp:TextBox ID="TextBox2" runat="server" Width="38px"></asp:TextBox>
    &nbsp; Operation Time
    <asp:TextBox ID="TextBox3" runat="server" Width="38px"></asp:TextBox>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Annual Kw Used
    <asp:TextBox ID="TextBox4" runat="server" Width="50px"></asp:TextBox>
    <br />
    Currently charge per kw
    <asp:TextBox ID="TextBox5" runat="server" Width="38px"></asp:TextBox>
    &nbsp;Annual Cost
    <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
    <br />

    </div>
    <p align="center">
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:Button ID="Button2" runat="server" Text="Button" />
    </p>
    </form>
    </body>
    </html>



    This is the vb code:


    Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    'CURRENT FIXTURE part 1
    Dim a As Integer = TextBox1.Text
    Dim b As Integer = TextBox2.Text
    Dim c As Integer = TextBox3.Text

    Dim annualKw As Integer = a * b * c * 365

    Dim annualKwFormat As Integer
    annualKwFormat = Format(annualKw, "#,###,")

    TextBox4.Text = annualKwFormat

    'CURRENT FIXTURE part 2
    'Multiply the annual Kw usage * kw charged
    Dim annualCost As Integer = annualKwFormat * TextBox5.Text

    TextBox6.Text = annualCost
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
    MsgBox("yay")
    End Sub
    End Class

  8. #8
    New Member
    Join Date
    Feb 12
    Posts
    9

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    Don't think this would effect it but one thing I did do in the .config file is remove the code below, it was causing errors and I couldn't figure out why, removing it didn't effect the local project:

    <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
    </sectionGroup>
    </sectionGroup>
    </sectionGroup>
    </configSections>

    Using this structure stopped any errors but don't know if closing of each </sectionGroup> before <section name> would work:

    <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    </sectionGroup>
    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    </sectionGroup>
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    </configSections>
    Last edited by moto485; Aug 9th, 2012 at 05:08 PM.

  9. #9
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,838

    Re: asp.net page not returning any results, no msgbox() when clicked extra..

    Hello,

    Due to the Format that you are using, if for whatever reason the resulting number is zero, you will get an empty string placed into the TextBox, which I suspect might be part of the problem you are having.

    I would suggest that you look into using Double.TryParse to grab your input values, this way you can be sure that what you are getting from the user is valid data. As an example, take a look at this:

    Code:
    Partial Public Class _Default
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            'CURRENT FIXTURE part 1
            Dim a As Double
            Dim b As Double
            Dim c As Double
            Dim d As Double
    
            If Not Double.TryParse(TextBox1.Text, a) Then
                Throw New ArgumentException("Unable to validate the Light Wattage Input")
            End If
    
            If Not Double.TryParse(TextBox2.Text, b) Then
                Throw New ArgumentException("Unable to validate the QTY Input")
            End If
    
            If Not Double.TryParse(TextBox3.Text, c) Then
                Throw New ArgumentException("Unable to validate the Operation Time Input")
            End If
    
            Dim annualKw As Double = a * b * c * 365
    
            TextBox4.Text = Format(annualKw, "#,###,")
    
            If Not Double.TryParse(TextBox5.Text, d) Then
                Throw New ArgumentException("Unable to validate the charge per kw Input")
            End If
    
            'CURRENT FIXTURE part 2
            'Multiply the annual Kw usage * kw charged
            Dim annualCost As Integer = annualKw * d
    
            TextBox6.Text = Format(annualCost, "#,###,")
        End Sub
    
        Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
            MsgBox("yay")
        End Sub
    End Class
    In this sample I am simply throwing an exception when something goes wrong, but you would most likely want to handle this a bit more gracefully.

    Hope that helps!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •