sending SMS from my application to Phones

Object reference not set to an instance of an object

Page 1 of 1

2 Replies - 1571 Views - Last Post: 22 July 2010 - 07:30 AM

#1 Guest_Oluwasegun Olaniyi femi*


Reputation:

sending SMS from my application to Phones

Posted 21 July 2010 - 12:08 PM

This the error That was occuring whennever i compile to run my application please help out."Object reference not set to an instance of an object"

please help me trace out my error from my codes
<asp:GridView ID="gvSendmess" runat="server" AutoGenerateColumns="False" 
                                DataKeyNames="ProductItemID" DataSourceID="SqlDataSource3" 
                                style="margin-bottom: 10px">
                                <Columns>
                                    <asp:TemplateField HeaderText="ProductItemID" InsertVisible="False" 
                                        SortExpression="ProductItemID">
                                        <EditItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductItemID") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <table style="width: 98%; height: 177px">
                                                <tr>
                                                    <td style="width: 134px">
                                                        Name</td>
                                                    <td>
                                                        <asp:TextBox ID="txtsendername" runat="server"></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 134px">
                                                        Sender's
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="txtsender" runat="server"></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 134px">
                                                        Receipent</td>
                                                    <td>
                                                        <asp:TextBox ID="txtrecipent" runat="server" Text='<%# Bind("PhoneNo") %>' 
                                                            ReadOnly="True"></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 134px">
                                                        &nbsp;</td>
                                                    <td>
                                                        <textarea ID="txteramessage" name="S1" rows="2" style="width: 264px"></textarea></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 134px">
                                                        &nbsp;</td>
                                                    <td>
                                                        <input type="checkbox" id="CheckboxUnicode" runat="server" NAME="CheckboxUnicode">Send 
                                                        message as Unicode </input> </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 134px">
                                                        Result</td>
                                                    <td>
                                                        <input size="50" type="text" id="TextResult" runat="server" NAME="TextResult"></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 134px">
                                                        Provider response</td>
                                                    <td>
                                                        <input size="50" type="text" id="TextResponse" runat="server" 
                                                            NAME="TextResponse" style="width: 308px"></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 134px">
                                                        &nbsp;</td>
                                                    <td>
                                                        <asp:Button ID="btnSendMes" runat="server" onclick="btnSendMes_ServerClick" 
                                                            Text="Send message" style="width: 131px" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>



Code behind is
Imports System.Data
Imports System.Data.SqlClient
Imports AXmsCtrl
Public Class pages_SendSMS
    Inherits System.Web.UI.Page
    Protected WithEvents txtrecipent As System.Web.UI.HtmlControls.HtmlInputText
    Protected WithEvents txteramessage As System.Web.UI.HtmlControls.HtmlTextArea
    Protected WithEvents CheckboxUnicode As System.Web.UI.HtmlControls.HtmlInputCheckBox
    Protected WithEvents txtresult As System.Web.UI.HtmlControls.HtmlInputText
    Protected WithEvents txtresponse As System.Web.UI.HtmlControls.HtmlInputText
    Protected WithEvents txtsender As System.Web.UI.HtmlControls.HtmlInputText
    Protected WithEvents btnSendMes As System.Web.UI.HtmlControls.HtmlInputButton
    

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private objHttpProtocol As SmsProtocolHttp
    Private objSmsMessage As SmsMessage
    Private objSmsConstants As SmsConstants

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
        objHttpProtocol = New SmsProtocolHttp()
        objSmsMessage = New SmsMessage()
        objSmsConstants = New SmsConstants()
    End Sub
    Protected Sub btnSendMes_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendMes.ServerClick
        ' Clear all properties
        objHttpProtocol.Clear()

        ' Provider Settings
        objHttpProtocol.ProviderHost = "www.gainz.com"
        objHttpProtocol.ProviderPort = 8080

        objHttpProtocol.ProviderErrorResponse = "ERR" ' Response should NOT contain 'ERR'
        objHttpProtocol.ProviderSuccessResponse = "id"  ' Response should contain 'id'

        ' URL Templates
        objHttpProtocol.URLText = "/SMS/SendSMS.asp?username=Gainz&password=cu2003&text=%MESSAGEDATA%&to=%MESSAGERECIPIENT%&from=%MESSAGESENDER%"
        objHttpProtocol.URLBinary = "/SMS/SendSMS.asp?username=Gainz&password=cu2003&text=%MESSAGEDATA%&to=%MESSAGERECIPIENT%&from=%MESSAGESENDER%&data=1"
        objHttpProtocol.URLUnicode = "/SMS/SendSMS.asp?username=Gainz&password=cu2003&text=%MESSAGEDATA%&to=%MESSAGERECIPIENT%&from=%MESSAGESENDER%&unicode=1"

        ' SMS Message Properties
        objSmsMessage.Sender = txtsender.Value
        objSmsMessage.Data = txteramessage.Value

        If (CheckboxUnicode.Checked = True) Then
            objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_UNICODE
        Else
            objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_TEXT
        End If

        objSmsMessage.Recipient = "+2347033233746"

        btnSendMes.Disabled = True

        objHttpProtocol.Send(objSmsMessage)

        btnSendMes.Disabled = False

        txtresult.Value = "ERROR #" & objHttpProtocol.LastError & " (" & objHttpProtocol.GetErrorDescription(objHttpProtocol.LastError) & ")"
        txtresponse.Value = objHttpProtocol.ProviderResponse

    End Sub

   End Class



Edited by macosxnerd101: Welcome to DIC! :) Please post your code using code tags, like so: :code:.

Is This A Good Question/Topic? 0

Replies To: sending SMS from my application to Phones

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5951
  • View blog
  • Posts: 23,212
  • Joined: 23-August 08

Re: sending SMS from my application to Phones

Posted 21 July 2010 - 06:11 PM

Moved to ASP.NET
Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: sending SMS from my application to Phones

Posted 22 July 2010 - 07:30 AM

Which line of code is the error message pointing too?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1