Saturday, March 31, 2012

Submitting a web form to a web server from a running windows servive.

hi and help. i have a windows service, in wich i want to submite a web from to a web server with some hidden fiels. how do i do this. and afterwords how can i get response from web server in windows service.
----------
From: Muhammad Saifullah

--------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>i6K//UAKUk2P/CaV2/rNFA==</Id>look up HttpWebRequest

Submitting a web form to a web server from a running windows servive.

hi and help. i have a windows service, in wich i want to submite a web from
to a web server with some hidden fiels. how do i do this. and afterwords how
can i get response from web server in windows service.
--
From: Muhammad Saifullah
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>i6K//UAKUk2P/CaV2/rNFA==</Id>look up HttpWebRequest

submitting a PDF form

I have a pdf form with form fields. I want to submit the values and post them to a database. I created a save button and the action is "Submit form". It calls an aspx file. When I try to write out the request variables I get none. For some reason none are getting posted. What am i doing wrong?
I have been trying to figure this out for quite some time and I am getting a bit frustrated, any help would be greatly appreciated.
Thanks.Code would be useful. What does the command look like that's attempting to write to the db? Is the information supplied to gain access to the db correct? Are the table/field names correct? Is your syntax correct?
The reason that I didnt bother posting any code is because I am getting stuck before the point that I try to put the info into the db. I cant even retrieve the form variables
Request.form("name of filed from pdf form")
this value gives me nothing.
My question is if there is something that I am supposed to be doing in the PDF form that should make this work.
thanks.
http://www.tgreer.com/pdfSubmit.html

Submitting data to sql

I am new to asp.net. I was wondering if some one can help be out with something
this is what I have for my submit button
Me.txtprocess.Text.Insert()

all I am trying to do is when a user puts an entry in and click submit the entry is written over to a sql table.

Thanks in advanceJust do something like...

Dim strSQL As String ' SQL Statement
Dim cmd As New SqlClient.SqlCommand ' SQL Command
Dim strSubject As String ' Subject String

' Set the SQL connection to use for SQL Command
cmd.Connection = New SqlClient.SqlConnection("Persist Security Info=False;server=MyServer;database=MyDB;User ID=sa;Password=MyPassword")

' Add neccessary parameters to the SQL Command
cmd.Parameters.Add("@.MyData", txtMyData.Text)

' SQL UPDATE Statement
strSQL = "INSERT INTO MyTable (MyColumn) Values (MyData)"

' Try to catch any exceptions
Try
' if the SQL Connection is closed, open it
If SqlConn.State = ConnectionState.Closed Then
SqlConn.Open()
End If

' Set the SQL Command SQL Statement
cmd.CommandText = strSQL

' Execute the SQL Insert or Update
cmd.ExecuteNonQuery()

' Catch any exceptions
Catch ex As Exception

' Finally if it excepts or not
Finally
' If the SQL Connection is open, close it
If SqlConn.State = ConnectionState.Open Then
SqlConn.Close()
End If

End Try

Submitting Data to Another Page Using ASP.NET

I need to post an ASP.NET form between sites for report processing.
Site A contains the asp.net forms and site B contains Java Servlets for
report processing.

All form fields values must be passed to the reporting servlet via http
post method. No parameters can be transmitted by URL. The report must
display in a NEW browser window. Does anyone know how to set a target
using httpwebrequest or is there another alternative?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Hi Dennis,

I've had success doing that using the Webclient class. You need to know
exactly what form field names the target expects.

Not sure about setting it to open in a new page.

Anyway, here's some code to give you an idea:

Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)
' Response.Redirect("http://msdn.microsoft.com/")
End Sub

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Call DoPost()
End Sub

<form id="Form1" method="post" runat="server">
<P>
<asp:TextBox id="TextBox1" runat="server">test</asp:TextBox></P>
<P>
<asp:Label id="Label1" runat="server">Label</asp:Label></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
</form
Ken
Microsoft MVP [ASP.NET]
Toronto

<Dennis E. Jones>; "Jr." <djone2@.jcpenney.com> wrote in message
news:e1jFoNTCFHA.520@.TK2MSFTNGP09.phx.gbl...
>I need to post an ASP.NET form between sites for report processing.
> Site A contains the asp.net forms and site B contains Java Servlets for
> report processing.
> All form fields values must be passed to the reporting servlet via http
> post method. No parameters can be transmitted by URL. The report must
> display in a NEW browser window. Does anyone know how to set a target
> using httpwebrequest or is there another alternative?
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Yes, that works...but I still need a solution for the target attribute.
Thanks for your help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
If all you want is a submit button that opens your servlet in a new
window, .NET never comes into play:

<form action="yourServlet.jsp" target="_blank" method="post">
<input type=...>
<input type="submit">
</form
Retarget your form from the HTML side.
Jason
http://www.expatsoftware.com
If I do not use .NET, then my server controls also go away....I guess a
javascript injected into the page on postback would work, but only for
those browsers that support Javascript.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Submitting Data to Another Page Using ASP.NET

I need to post an ASP.NET form between sites for report processing.
Site A contains the asp.net forms and site B contains Java Servlets for
report processing.
All form fields values must be passed to the reporting servlet via http
post method. No parameters can be transmitted by URL. The report must
display in a NEW browser window. Does anyone know how to set a target
using httpwebrequest or is there another alternative?
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Hi Dennis,
I've had success doing that using the Webclient class. You need to know
exactly what form field names the target expects.
Not sure about setting it to open in a new page.
Anyway, here's some code to give you an idea:
Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)
' Response.Redirect("http://msdn.microsoft.com/")
End Sub
Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Call DoPost()
End Sub
<form id="Form1" method="post" runat="server">
<P>
<asp:TextBox id="TextBox1" runat="server">test</asp:TextBox></P>
<P>
<asp:Label id="Label1" runat="server">Label</asp:Label></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
</form>
Ken
Microsoft MVP [ASP.NET]
Toronto
<Dennis E. Jones>; "Jr." <djone2@.jcpenney.com> wrote in message
news:e1jFoNTCFHA.520@.TK2MSFTNGP09.phx.gbl...
>I need to post an ASP.NET form between sites for report processing.
> Site A contains the asp.net forms and site B contains Java Servlets for
> report processing.
> All form fields values must be passed to the reporting servlet via http
> post method. No parameters can be transmitted by URL. The report must
> display in a NEW browser window. Does anyone know how to set a target
> using httpwebrequest or is there another alternative?
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
Yes, that works...but I still need a solution for the target attribute.
Thanks for your help.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
If I do not use .NET, then my server controls also go away....I guess a
javascript injected into the page on postback would work, but only for
those browsers that support Javascript.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Submitting form doesnt update .Text

Hi!
I have this form that I use, both for adding records and for updating. When submitted, it checks if the Reuqest.Querystring("pid") i set, if not it adds a new record, otherwise it should update the current record (based on pid).
There are no problems if I add a record, but on update, the values in the form doesn't follow.
The basic structure is this:

Sub saveNews(Byval id)
'When I use this on an update, the values in name.Text and pbody.Text aren't the ones entered, but the previous values in the textboxes (or database).
If id <>""Then'Update dbElse'Add new recordEnd IfEnd SubSub btnSave()Call saveNews(Request.Querystring("pid")End Sub

Sub fEditFrm(ByVal id)
'Here I fetch the columns based on id
If objDR.HasRows Then
pbody.Text = objDR("pbody")
name.Text = objDR("name")
date_created.Text = objDR("date_created")
End If
End Sub

Sub Page.Load()'This checks which page you're onSelect Case Request.Querystring("page")Case"addnew" news.SetActiveView(editnews)Case"edit" news.SetActiveView(editnews)Call fEditFrm(Request.QueryString("pid"))'This one fetches the record and populates the textboxesEnd Sub


Is my problem understandable at all?
Thanks you alot!
/MartinI found the problem. Apparently the sub fEditFrm (which populate the form with db entry) executes before the update in saveNews(), so the textboxes reverted to the original values... I added an 'If Not Page.IsPostback' before the Call fEditFrm and it worked.
But then I have another question:
How can you check in which order things are executed? I come from classic ASP and it wasn't too hard to do things like this. Btw, I'm using VWD Express edition.

Enable tracing on the Page...

<%#@. Page Trace="true" TraceMode="SortByTime"%>

Then run the page. At the bottom you will see everything that is going on inside the page.


Thanks!
That was very useful, in Classic ASP I have this subroutine that spits out that info but this was much easier :)

Question though; is it possible to put that trace into a master page so you don't have to edit every single page?

Thanks again!
/Martin

You can enable trace for all pages in the web.config file, which looks something like this:

<configuration><web.config><trace enabled="true" traceMode="SortByTime" localOnly="false" /></web.config></configuration>

Thanks alot! I'll try it as soon as it's possible!

submitting form values

Hi all, (fyi, I know ASP well, .NET is new)

ok, submitting a form. Few things:

1. the form is a custom collage of textboxes, no formview, no detailsview, just textboxes, dropdownlists, and datavalidators.

2. The form get populated via querystring'd 'UserID' as so:---------------

Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim strSQL As String
Dim myDataReader As OleDbDataReader

Session.Item("CurrentUserIDtoEdit") = Request.QueryString("UserID")

strSQL = "SELECT * FROM Users " _
& "WHERE uniqueid='" & Session.Item("CurrentUserIDtoEdit") & "'"

myConnection = New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("strConn"))

myCommand = New OleDbCommand(strSQL, myConnection)

myConnection.Open()
myDataReader = myCommand.ExecuteReader()
Do While (myDataReader.Read())
TextboxFirstName.Text = Convert.ToString(myDataReader("FirstName"))
TextboxLastName.Text = Convert.ToString(myDataReader("LastName"))
TextboxAddress1.Text = Convert.ToString(myDataReader("Address1"))
TextboxAddress2.Text = Convert.ToString(myDataReader("Address2"))
TextboxCity.Text = Convert.ToString(myDataReader("City"))
DropDownState.SelectedValue = Convert.ToString(myDataReader("State"))
TextBoxZipCode.Text = Convert.ToString(myDataReader("Zip"))
TextBoxPhone.Text = Convert.ToString(myDataReader("Phone"))
TextBoxEmail.Text = Convert.ToString(myDataReader("emailaddress"))
TextboxUsername.Text = Convert.ToString(myDataReader("Username"))
TextboxPassword.Text = Convert.ToString(myDataReader("Password"))
DropDownListPermissionLevel.SelectedValue = myDataReader("PermissionLevel")
CheckBoxDeleted.Checked = Convert.ToBoolean(myDataReader("Deleted"))
Loop
myDataReader.Close()
myConnection.Close()

--------------THIS WORKS GREAT

Question is, this page is a 'Modify User' page. What I want is it to populate with current 'User' data from the DB (that's working fine. as above)

AND, when resubmitted, update the DB with the new data from the form, show a 'success label' of some sort with a minor delay, and response.redirect to 'Menu.aspx'

isPostBack is an option, yes...but how to integrate that conditional coding with a SQLDataObject? or do I hard code the update like the above code...and how?

(I have the Stored Procedure as follows)----------

CREATE PROCEDURE dbo.UpdateUser
(
@dotnet.itags.org.UniqueID int,
@dotnet.itags.org.FirstName nvarchar(50),
@dotnet.itags.org.LastName nvarchar(50),
@dotnet.itags.org.Address1 nvarchar(100),
@dotnet.itags.org.Address2 nvarchar(100),
@dotnet.itags.org.City char(100),
@dotnet.itags.org.State char(2),
@dotnet.itags.org.Zip char(5),
@dotnet.itags.org.Phone char(10),
@dotnet.itags.org.emailaddress nvarchar(100),
@dotnet.itags.org.Username nvarchar(50),
@dotnet.itags.org.Password nvarchar(50),
@dotnet.itags.org.PermissionLevel char(1),
@dotnet.itags.org.Deleted bit,
@dotnet.itags.org.SystemUserID int

)
AS
SET NOCOUNT OFF;
UPDATE Users
SET
FirstName = @dotnet.itags.org.FirstName,
LastName = @dotnet.itags.org.LastName,
Address1 = @dotnet.itags.org.Address1,
Address2 = @dotnet.itags.org.Address2,
City = @dotnet.itags.org.City,
State = @dotnet.itags.org.State,
Zip = @dotnet.itags.org.Zip,
Phone = @dotnet.itags.org.Phone,
emailaddress = @dotnet.itags.org.emailaddress,
username = @dotnet.itags.org.Username,
[Password] = @dotnet.itags.org.Password,
PermissionLevel = @dotnet.itags.org.PermissionLevel,
Deleted = @dotnet.itags.org.Deleted,

LastModifiedBy = @dotnet.itags.org.SystemUserID,
LastModifiedDate = CURRENT_TIMESTAMP

where Uniqueid = @dotnet.itags.org.UniqueID
GO

-----------

Do I somehow, link the SQLDataobject with the 'onclick' event of the 'submit' button?

NOTE: I figured out that the SQLDataobject has an updatecommandtype and an updatequery property panel where I set the params for the SP correctly to the form vars and session.items so it's ready to go...

---

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ProductionConnectionString %>"
InsertCommand="InsertUser" InsertCommandType="StoredProcedure" SelectCommand="GetUser"
SelectCommandType="StoredProcedure" UpdateCommand="UpdateUser" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:SessionParameter Name="UniqueID" SessionField="CurrentUserIDtoEdit" Type="Int32" />
<asp:ControlParameter ControlID="TextboxFirstName" Name="FirstName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxLastName" Name="LastName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxAddress1" Name="Address1" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxAddress2" Name="Address2" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxCity" Name="City" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="DropDownState" Name="State" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="TextBoxZipCode" Name="Zip" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="TextBoxPhone" Name="Phone" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="TextBoxEmail" Name="emailaddress" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxUsername" Name="Username" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxPassword" Name="Password" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="DropDownListPermissionLevel" Name="PermissionLevel"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="CheckBoxDeleted" Name="Deleted" PropertyName="Checked"
Type="Boolean" />
<asp:SessionParameter Name="SystemUserID" SessionField="UserID" Type="Int32" />
<asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter DefaultValue="" Name="UserID" QueryStringField="UserID"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Address1" Type="String" />
<asp:Parameter Name="Address2" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="emailaddress" Type="String" />
<asp:Parameter Name="Username" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="PermissionLevel" Type="String" />
<asp:Parameter Name="CurrentUserID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
<table>
<tr>
<td colspan="3" align="left"><asp:Label ID="Label1" runat="server" Text="Modify User" Font-Size="Large"></asp:Label></td>
</tr>
<tr>
<td style="height: 24px">First Name</td>
<td style="height: 24px"><asp:TextBox ID="TextboxFirstName" runat="server"></asp:TextBox></td>
<td style="height: 24px"><asp:RequiredFieldValidator ID="RequiredFieldValidatorFirstName" runat="server" ControlToValidate="TextboxFirstName"
ErrorMessage="First Name Required"></asp:RequiredFieldValidator> </td>
</tr>
<tr>
<td>Last Name</td>
<td><asp:TextBox ID="TextboxLastName" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidatorLastName" runat="server"
ControlToValidate="TextboxLastName" ErrorMessage="Last Name Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Address 1</td>
<td><asp:TextBox ID="TextboxAddress1" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidatorAddress1" runat="server"
ControlToValidate="TextboxAddress1" ErrorMessage="Address Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Address 2</td>
<td><asp:TextBox ID="TextboxAddress2" runat="server"></asp:TextBox></td>
<td></td>
</tr>
<tr>
<td>City</td>
<td><asp:TextBox ID="TextboxCity" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldCity" runat="server"
ControlToValidate="TextboxCity" ErrorMessage="City Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>State</td>
<td><asp:DropDownList id="DropDownState" runat="server"
<asp:ListItem Value="AL">Alabama</asp:ListItem
<asp:ListItem Value="AK">Alaska</asp:ListItem
<asp:ListItem Value="AZ">Arizona</asp:ListItem
<asp:ListItem Value="AR">Arkansas</asp:ListItem
<asp:ListItem Value="CA">California</asp:ListItem
<asp:ListItem Value="CO">Colorado</asp:ListItem
<asp:ListItem Value="CT">Connecticut</asp:ListItem
<asp:ListItem Value="DC">District of Columbia</asp:ListItem
<asp:ListItem Value="DE">Delaware</asp:ListItem
<asp:ListItem Value="FL">Florida</asp:ListItem
<asp:ListItem Value="GA">Georgia</asp:ListItem
<asp:ListItem Value="HI">Hawaii</asp:ListItem
<asp:ListItem Value="ID">Idaho</asp:ListItem
<asp:ListItem Value="IL">Illinois</asp:ListItem
<asp:ListItem Value="IN">Indiana</asp:ListItem
<asp:ListItem Value="IA">Iowa</asp:ListItem
<asp:ListItem Value="KS">Kansas</asp:ListItem
<asp:ListItem Value="KY">Kentucky</asp:ListItem
<asp:ListItem Value="LA">Louisiana</asp:ListItem
<asp:ListItem Value="ME">Maine</asp:ListItem
<asp:ListItem Value="MD">Maryland</asp:ListItem
<asp:ListItem Value="MA">Massachusetts</asp:ListItem
<asp:ListItem Value="MI">Michigan</asp:ListItem
<asp:ListItem Value="MN">Minnesota</asp:ListItem
<asp:ListItem Value="MS">Mississippi</asp:ListItem
<asp:ListItem Value="MO">Missouri</asp:ListItem
<asp:ListItem Value="MT">Montana</asp:ListItem
<asp:ListItem Value="NE">Nebraska</asp:ListItem
<asp:ListItem Value="NV">Nevada</asp:ListItem
<asp:ListItem Value="NH">New Hampshire</asp:ListItem
<asp:ListItem Value="NJ">New Jersey</asp:ListItem
<asp:ListItem Value="NM">New Mexico</asp:ListItem
<asp:ListItem Value="NY">New York</asp:ListItem
<asp:ListItem Value="NC">North Carolina</asp:ListItem
<asp:ListItem Value="ND">North Dakota</asp:ListItem
<asp:ListItem Value="OH">Ohio</asp:ListItem
<asp:ListItem Value="OK">Oklahoma</asp:ListItem
<asp:ListItem Value="OR">Oregon</asp:ListItem
<asp:ListItem Value="PA">Pennsylvania</asp:ListItem
<asp:ListItem Value="RI">Rhode Island</asp:ListItem
<asp:ListItem Value="SC">South Carolina</asp:ListItem
<asp:ListItem Value="SD">South Dakota</asp:ListItem
<asp:ListItem Value="TN">Tennessee</asp:ListItem
<asp:ListItem Value="TX">Texas</asp:ListItem
<asp:ListItem Value="UT">Utah</asp:ListItem
<asp:ListItem Value="VT">Vermont</asp:ListItem
<asp:ListItem Value="VA">Virginia</asp:ListItem
<asp:ListItem Value="WA">Washington</asp:ListItem
<asp:ListItem Value="WV">West Virginia</asp:ListItem
<asp:ListItem Value="WI">Wisconsin</asp:ListItem
<asp:ListItem Value="WY">Wyoming</asp:ListItem
</asp:DropDownList>
</td>
<td></td>
</tr>
<tr>
<td>Zip Code</td>
<td><asp:TextBox ID="TextBoxZipCode" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator id="RegularExpressionValidatorZipCode" runat="server" ErrorMessage="Zip format (12345-1234) last four optional" ControlToValidate="TextBoxZipCode" ValidationExpression="\d{5}(-\d{4})?"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Phone</td>
<td><asp:TextBox ID="TextBoxPhone" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator ID="RegularExpressionValidatorPhone" runat="server" ErrorMessage="Phone Format (1234567890)" ControlToValidate="TextBoxPhone" ValidationExpression="((\(\d{3}\) ?)|(\d{3}))?\d{3}\d{4}"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>Email</td>
<td><asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator id="RegularExpressionValidatorEmail" runat="server" ErrorMessage="Email format (a@dotnet.itags.org.a.com)" ControlToValidate="TextBoxEmail" ValidationExpression="\w+([-+.']\w+)*@dotnet.itags.org.\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Username</td>
<td><asp:TextBox ID="TextboxUsername" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator ID="RegularExpressionValidatorUsername" runat="server" ErrorMessage="Username must be 4 chars long and start with a letter." ControlToValidate="TextboxUsername" ValidationExpression="^[A-Za-z]\w{3,}$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>Password</td>
<td><asp:TextBox ID="TextboxPassword" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidatorPassword" runat="server"
ControlToValidate="TextboxPassword" ErrorMessage="Password Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Permission Level</td>
<td><asp:DropDownList ID="DropDownListPermissionLevel" runat="server">
<asp:ListItem Selected="True">Select One...</asp:ListItem>
<asp:ListItem Value="1">Admin</asp:ListItem>
<asp:ListItem Value="2">Manager</asp:ListItem>
</asp:DropDownList></td>
<td></td>
</tr>
<tr>
<td>Deleted</td>
<td><asp:CheckBox ID="CheckBoxDeleted" runat="server" /></td>
<td></td>
</tr>

<tr><td colspan="3">
<asp:ValidationSummary ID="ValidationSummaryAddUser" runat="server" />
</td></tr>
<tr>
<td style="height: 24px"><asp:Button ID="ResetButton" runat="server" Text="Reset" /></td>
<td style="height: 24px"><asp:Button ID="SubmitButton" runat="server" Text="Submit" /></td>
<td style="height: 24px"></td>
</tr>
</table>


</div>
</asp:Content>

---

just how to make the SQLDataobject and submit button onclick to like each other?

Thanks again all.

Hi,

Based on your description, I understand that you have created a SqlDataSource control on a table, and have created Select, Insert and Update command on it. If there is any misunderstanding, please feel free to let me know.

Usually, the Select command is fired by calling DataBind method on the controls. When binding, the method is called and the returned DataReader or DataSet is automatically bind to the controls.

For Update and Insert method, you will have to call the Update() or Insert() manually. In your case, call SqlDataSource1.Update() in the Submit button. If it's a newly added record, call SqlDataSource1.Insert().

If you need to know if the record has been added, you can use IF EXISTS statement to check existence in database.

IF EXISTS (SELECT * FROM t1 WHERE id = @.id)
BEGIN
--Call Update
END
ELSE
BEGIN
--Call Insert
END

Hope this helps.


Thank you for your reply.

Since my post, I've been non-stop .NET-in-ating and I've learned much. I wound up doing the following

Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim intUserCount As Integer
Dim strSQL As String

strSQL = "Insert into Users " _
& "(FirstName, LastName, Username, Password, Permissionlevel)" _
& "VALUES ('" & Trim(Replace(TextboxFirstName.Text, "'", "''")) & "','" _
& Trim(Replace(TextboxLastName.Text, "'", "''")) & "','" _
& Trim(Replace(TextboxUsername.Text, "'", "''")) & "','" _
& Trim(Replace(TextboxPassword.Text, "'", "''")) & "','" _
& Trim(Replace(DropDownListPermissionLevel.SelectedItem.Value, "'", "''")) & "')"

myConnection = New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("strConn"))

myCommand = New OleDbCommand(strSQL, myConnection)

myConnection.Open()
intUserCount = myCommand.ExecuteScalar()
myConnection.Close()


End Sub

But now, I've learned how to modify the 'templates' for a gridview/detailsview combo. I'm an old ASP guy, as I've said. So, messing with this has been good exercise to understand what's going on.

Since this posting, I've changed my whole view of how a 'control panel' could/needs to be laid out. This new .NET stuff is changing my way of 'organizing control panel' type portions of web sites.

As an exercise I'm converting www.beaudamore.com/ProductionManagement form old ASP into ASP.NET using VB as the base code. The whole way the 'Menu' is laid out is going to change in respect to this whole new programming style. I'm envisioning it different, simpler, but equally powerful. I will post more, perhaps my view form old ASP will help other 'old timers' as well. I think I took too long to make the change.

Thanks again.

Submitting Form to Database

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.

For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.

I have a database table called tblName with a column called name where
the submitted names go.

How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.

Thanks,
BenIf you look at the ASP.NET QUICKSTART tutorials on the asp.net website, it
has lots of examples like this. QUICKSTARTS also installs as an option with
Visual Studio.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Ben" wrote:

Quote:

Originally Posted by

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.
>
For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.
>
I have a database table called tblName with a column called name where
the submitted names go.
>
How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.
>
Thanks,
Ben
>

Submitting Form to Database

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.
For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.
I have a database table called tblName with a column called name where
the submitted names go.
How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.
Thanks,
BenIf you look at the ASP.NET QUICKSTART tutorials on the asp.net website, it
has lots of examples like this. QUICKSTARTS also installs as an option with
Visual Studio.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Ben" wrote:

> I have an ASP.Net page created with a table I made to look like a form
> for our benefit request program. How do I code this properly to send
> it to a table in our database.
> For the sake of me learning how to do this lets just do short example
> like. I have an aspx page with a label for name and a text box where
> a user can input their name.
> I have a database table called tblName with a column called name where
> the submitted names go.
> How do I code it so the name is submitted, a confirmation page is
> shown and the data goes to the database when I click submit? Any help
> is greatly appreciated.
> Thanks,
> Ben
>

Submitting form from the Server Control

Hi,

the form data exists in the Request.Form collection. how do you mavigate
from Page1 to Page2?
if you use server.transfer make sure the the secound parameter set to
true otherwise the Form wont redirect to Page2.

Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Hi,

Thanks for the info. I was using Response.Redirect to redirect to the next
page. Because of that I was not getting the submitted value.

Regards

Pradeep

"Natty Gur" <natty@.dao2com.com> wrote in message
news:uBoQVf7ZDHA.1744@.TK2MSFTNGP12.phx.gbl...
> Hi,
> the form data exists in the Request.Form collection. how do you mavigate
> from Page1 to Page2?
> if you use server.transfer make sure the the secound parameter set to
> true otherwise the Form wont redirect to Page2.
> Natty Gur, CTO
> Dao2Com Ltd.
> 34th Elkalay st. Raanana
> Israel , 43000
> Phone Numbers:
> Office: +972-(0)9-7740261
> Fax: +972-(0)9-7740261
> Mobile: +972-(0)58-888377
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Hi,

One more thing. When i use Server.Transfer, the URL of the IE doesn't get
updated with the current form. Also it always displays the URL of the last
Form.

Any idea ?

Pradeep

"Natty Gur" <natty@.dao2com.com> wrote in message
news:uBoQVf7ZDHA.1744@.TK2MSFTNGP12.phx.gbl...
> Hi,
> the form data exists in the Request.Form collection. how do you mavigate
> from Page1 to Page2?
> if you use server.transfer make sure the the secound parameter set to
> true otherwise the Form wont redirect to Page2.
> Natty Gur, CTO
> Dao2Com Ltd.
> 34th Elkalay st. Raanana
> Israel , 43000
> Phone Numbers:
> Office: +972-(0)9-7740261
> Fax: +972-(0)9-7740261
> Mobile: +972-(0)58-888377
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Submitting form from the Server Control

Dear All,

How can I submit the whole form data when I click on the "ASP Server
Button". I want to use the Posted data in the redirect form.

Regards

PradeepHi,

What "whole form data means. Every form submits already sending all
the Input values to the server by default. If you want the entire HTML
add invisible Input box and put the body innerhtml in that input box
before submitting.

Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Submitting form with multiple onclick events

Hi

I'm building a custom control which basically takes data from the user
and then submits it. I would use the validator controls but if I
understand correctly (I've been working with .Net for 2 weeks) you
cant 'embed' them in the custom controls. Someone correct me if I'm
wrong (and please point to an example :) )

So, to get around this, I'm using Javascript. In my control, I'm doing

Writer.WriteAttribute("OnClick", "javascript:checkData();" &
Page.GetPostBackEventReference(Me, "Data"))

for an Input item so I get something like

<input type="button" value="Submit"
OnClick="javascript:checkData();__doPostBack('MyControl','D ata')" /
The checkData() function does this:

function checkLogin()
{
if (document.Data.item1.value == "" )
{
alert("Please enter item 1.");
return false;
}

if (document.Data.item2.value == "" )
{
alert("Please enter item 2.");
return false;
}

if (document.Data.item1.value != "" && document.Data.item2.value !=
"" )
{
return true;
}

}

My query is, how do I get the click event to fire correctly so that i
get alerts when there is a problem, and it passes through and submits
the form if there isnt a problem?

Thanks

SamHi,

Your client side script should use cancelBubble and returnValue to
disable event default process and raise alert if error found.

function CallServer()
{
if validate
{
__doPostBack('MyControl','Data');
}
else
{
alert("Error");
window.event.cancelBubble = true;
window.event.returnValue = false;
}
}

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Natty Gur <natty@.dao2com.com> wrote in message news:<uSSwHLhAEHA.3348@.TK2MSFTNGP11.phx.gbl>...
> Hi,
> Your client side script should use cancelBubble and returnValue to
> disable event default process and raise alert if error found.
> function CallServer()
> {
> if validate
> {
> __doPostBack('MyControl','Data');
> }
> else
> {
> alert("Error");
> window.event.cancelBubble = true;
> window.event.returnValue = false;
> }
> }
>
> HTH
> Natty Gur[MVP]
> blog : http://weblogs.asp.net/ngur
> Mobile: +972-(0)58-888377
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Thanks Natty

This means I have to create inline javascripts which I'd rather not do
if I can help it. Just as luck would have it, after spending an 'hour
or two' trying to find a solution before posting, 5 mins after posting
I find a solution :( Always the way...

Anyhow, just for reference purposes, what I've done is to validate on
OnMouseDown and postback on OnClick. Works a treat
Hi Samuel,

Its unfortunate that you had to rework validation because of some incorrect
information about validators. The ASP.NET validators work fine within custom
controls. They have one key limitation related to their "location": the
ControlToValidate must be associated with the ID of a control in the same
"naming container". If your custom control impliments INamingContainer,
ControlToValidate can only point to other controls within your custom
control. If not, it can refer to other controls in the same naming container
that your custom control appears. Some types of naming containers: Page,
UserControl, and rows in DataGrid and DataList.

If you wanted to support validation without naming container limits, I wrote
a replacement to Microsoft's validators that overcomes that limitation among
numerous others: Professional Validation And More.
http://www.peterblum.com/vam/home.aspx.

-- Peter Blum
www.PeterBlum.com
Email: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Samuel Hon" <noreply@.samuelhon.co.uk> wrote in message
news:c8672b7d.0403040703.c458604@.posting.google.co m...
> Hi
> I'm building a custom control which basically takes data from the user
> and then submits it. I would use the validator controls but if I
> understand correctly (I've been working with .Net for 2 weeks) you
> cant 'embed' them in the custom controls. Someone correct me if I'm
> wrong (and please point to an example :) )
> So, to get around this, I'm using Javascript. In my control, I'm doing
> Writer.WriteAttribute("OnClick", "javascript:checkData();" &
> Page.GetPostBackEventReference(Me, "Data"))
> for an Input item so I get something like
> <input type="button" value="Submit"
> OnClick="javascript:checkData();__doPostBack('MyControl','D ata')" />
> The checkData() function does this:
> function checkLogin()
> {
> if (document.Data.item1.value == "" )
> {
> alert("Please enter item 1.");
> return false;
> }
> if (document.Data.item2.value == "" )
> {
> alert("Please enter item 2.");
> return false;
> }
> if (document.Data.item1.value != "" && document.Data.item2.value !=
> "" )
> {
> return true;
> }
> }
> My query is, how do I get the click event to fire correctly so that i
> get alerts when there is a problem, and it passes through and submits
> the form if there isnt a problem?
> Thanks
> Sam
"Peter Blum" <PLBlum@.Blum.info> wrote in message news:<OC#ZP$uAEHA.624@.TK2MSFTNGP10.phx.gbl>...
> Hi Samuel,
> Its unfortunate that you had to rework validation because of some incorrect
> information about validators. The ASP.NET validators work fine within custom
> controls. They have one key limitation related to their "location": the
> ControlToValidate must be associated with the ID of a control in the same
> "naming container". If your custom control impliments INamingContainer,
> ControlToValidate can only point to other controls within your custom
> control. If not, it can refer to other controls in the same naming container
> that your custom control appears. Some types of naming containers: Page,
> UserControl, and rows in DataGrid and DataList.
> If you wanted to support validation without naming container limits, I wrote
> a replacement to Microsoft's validators that overcomes that limitation among
> numerous others: Professional Validation And More.
> http://www.peterblum.com/vam/home.aspx.
> -- Peter Blum
> www.PeterBlum.com
> Email: PLBlum@.PeterBlum.com
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
<snip
Thanks Peter for clearing that up, I will re-investigate

Sam

Submitting form with a unique ID

Hi All,

I'm looking for some information/code samples on how I can create a
simple web form that includes an auto-generated Unique ID on the form.

The form includes the following 3 fields (Unique ID, First Name and
Last Name). I have a SQL Server 2000 back-end with the table created
as follows:

UniqueID - numeric (9)
FirstName - varchar (50)
LastName - varchar (50)

Ideally I would like the user just to enter their First and Last Name
and the form automatically creates a Unique ID for them. Once they
type in their First/Last Name the user submits the information to the
database. I've managed to get the web form created so that it submits
the First/Last Name successfully but I can't think how to create the
Unique ID, ideally I'd like this to be based around the time/date of
submittal.

Any guidance would be much appreciated.

Thanks

ScottJames... If you declare an IDENTITY column, SQL will return a
uniqueID upon INSERT. If you want to generate your own
uniqueID you could do a concatenation of the MAC address of the
client ethernet card plus a timestamp.

Regards,
Jeff
>I've managed to get the web form created so that it submits
the First/Last Name successfully but I can't think how to create the
Unique ID, ideally I'd like this to be based around the time/date of
submittal.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Using a system generated GUID is quick and easy, although kinda long.
16 bytes minimum.

"James Brown" <i.m@.winning.com> wrote in message
news:1f88a50b.0307051028.3caafaf1@.posting.google.c om...
> Hi All,
> I'm looking for some information/code samples on how I can create a
> simple web form that includes an auto-generated Unique ID on the form.
> The form includes the following 3 fields (Unique ID, First Name and
> Last Name). I have a SQL Server 2000 back-end with the table created
> as follows:
> UniqueID - numeric (9)
> FirstName - varchar (50)
> LastName - varchar (50)
> Ideally I would like the user just to enter their First and Last Name
> and the form automatically creates a Unique ID for them. Once they
> type in their First/Last Name the user submits the information to the
> database. I've managed to get the web form created so that it submits
> the First/Last Name successfully but I can't think how to create the
> Unique ID, ideally I'd like this to be based around the time/date of
> submittal.
> Any guidance would be much appreciated.
> Thanks
> Scott

submitting in csharp

what's the equivalent of form.submit() "in javascript"
to c# ?
thanks!!!!

There is no equivalent. What are you wanting to do?


I have 3 tags <div id=... runat=server>
I want to view only one of them and hide the two others
I used the tag <select ... runat=server>
<option...>
...
I want to do this without javascript and without vbscript only c#!
I did not clearly understand your problem, but here is my best shot at it.
If you don't want to use javascript to submit a form, then use an asp 'Button' on the page to submit the form. You can drop an asp 'Button' from theToolbox>Web Forms to your page in design view. Then double click on this button to add code in code-behind for this button's click event. In this code you could set the 'Visible' property of the controls you want to hide. Make sure there is a runat='server' attribute for the controls you want to hide in the page's html code file i.e. in page's aspx file.
The asp 'Button', will by default, submit a form to web server for processing.
I hope this helps.

Submitting IFrame in asp.net

hi
I have this situation where I need to do some server side execution
without posting the page.
I used to do this in asp using IFrame, but it's not working in asp.net.
I had a form and iframe element in the web page as follow:
<form id=MainForm ...>
this is the form that the user see
</form>
<form id= myForm method=post action="form.aspx" target="myHiddenFrame">
<input type=hidden id=hiddenField>
</form>
<iframe id="myHiddenFrame" src=PortfolioName.aspx name="myHiddenFrame"
style="width:0px; height:0px; border: 0px"></iframe>
then I had a javascript function: window.myForm.submit();
It seems that i can't put target="myHiddenFrame", the target can only be
_self, _parent...
How can I submit in an IFrame element ?
regards
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!iframe is working in asp.net in the regular way. It just has to sit inside a
form. And there can be only one form in a page. And there should be
runat=server set for the form tag.
Eliyahu
"Naim" <anonymous@.devdex.com> wrote in message
news:%23YXooBz7EHA.3592@.TK2MSFTNGP09.phx.gbl...
> hi
> I have this situation where I need to do some server side execution
> without posting the page.
> I used to do this in asp using IFrame, but it's not working in asp.net.
> I had a form and iframe element in the web page as follow:
> <form id=MainForm ...>
> this is the form that the user see
> </form>
> <form id= myForm method=post action="form.aspx" target="myHiddenFrame">
> <input type=hidden id=hiddenField>
> </form>
> <iframe id="myHiddenFrame" src=PortfolioName.aspx name="myHiddenFrame"
> style="width:0px; height:0px; border: 0px"></iframe>
> then I had a javascript function: window.myForm.submit();
> It seems that i can't put target="myHiddenFrame", the target can only be
> _self, _parent...
> How can I submit in an IFrame element ?
> regards
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!

Submitting IFrame in asp.net

hi

I have this situation where I need to do some server side execution
without posting the page.
I used to do this in asp using IFrame, but it's not working in asp.net.

I had a form and iframe element in the web page as follow:
<form id=MainForm ...>
this is the form that the user see
</form>
<form id= myForm method=post action="form.aspx" target="myHiddenFrame">
<input type=hidden id=hiddenField>
</form
<iframe id="myHiddenFrame" src=PortfolioName.aspx name="myHiddenFrame"
style="width:0px; height:0px; border: 0px"></iframe
then I had a javascript function: window.myForm.submit();

It seems that i can't put target="myHiddenFrame", the target can only be
_self, _parent...

How can I submit in an IFrame element ?

regards

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!iframe is working in asp.net in the regular way. It just has to sit inside a
form. And there can be only one form in a page. And there should be
runat=server set for the form tag.

Eliyahu

"Naim" <anonymous@.devdex.com> wrote in message
news:%23YXooBz7EHA.3592@.TK2MSFTNGP09.phx.gbl...
> hi
> I have this situation where I need to do some server side execution
> without posting the page.
> I used to do this in asp using IFrame, but it's not working in asp.net.
> I had a form and iframe element in the web page as follow:
> <form id=MainForm ...>
> this is the form that the user see
> </form>
> <form id= myForm method=post action="form.aspx" target="myHiddenFrame">
> <input type=hidden id=hiddenField>
> </form>
> <iframe id="myHiddenFrame" src=PortfolioName.aspx name="myHiddenFrame"
> style="width:0px; height:0px; border: 0px"></iframe>
> then I had a javascript function: window.myForm.submit();
> It seems that i can't put target="myHiddenFrame", the target can only be
> _self, _parent...
> How can I submit in an IFrame element ?
> regards
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Submitting HTML page data through form.

Hi,

Iam trying to submit data using form.
I have taken Text area in the form.
I want to submit Html page data(data is something like <Html> <body> hello</body></html>)
through this form.

But it is giving error. How to handle this situation

Server Error in '/webs' Application.
------------------------

A potentially dangerous Request.Form value was detected from the client (ta=" <html><head></head><...").Please read the following:
Request Validation - Preventing Script Attacks

It will show you how you can effectively "turn off" this error. However, youmust take notice of the warnings in red text. Do not just turn off the error, without validating the input yourself.
Hi,

.NET 1.1 has built in protection against script injections through textbox, textareas etc., However, if you are sure that your users won't do the hacking, you can remove this checking functionality by adding the ValidateRequest="false" to the @.Page directive of your aspx page.

If you want this for whole of your application, you can specify the same in the web.config

Hope it helps.
Hello
Thanks for help.

It is working fine.

But While printing the result it is printing like
<html><head></head><body>hello</body></html>
How to handle this situation.
Hi there,

You will have to decode the information before actually bind to a control.

for e.g

Text1.text = Server.htmldecode(dr("myHtml).tostring)

HTH
Thanks to all .
It is running fine.

submitting the form to the browser

I am very new to ASP.NET. We have an asp.NET project that is used to show the state of various sql tables/data. The "proposed enhancement" to that is when the data is updated locally (through another application running on the same network where the database is located), the browser (if someone happen to view the same data over the Internet through a browser) should refresh automatically so that the data is ~accurate~ when viewed. I know that browser uses pull technology, and in order to receive a new data, the browser must "request" it (through a control-generated event or a refresh event generated through timer). When the form is posted back to the server and resubmitted, it will "refresh" the browser view. Since the data must appear on the browser within 10-20 seconds of the actual data update, the refresh must be done quite frequently, and the page will constantly reload, so because of that I am not eager to generate refresh events on timer. Is there any way I can push the newly updated page to the browser from the server without any interaction/request from the browser? Is anybody aware of any other technology that I can use it to accomplish this task? ANy help/hint/suggestions are greatly appreciated.

Thank you
olaHi ola,

Unfortunately, there is no other technology that will help you with this issue. You are correct in that the brower uses "pull" technology and therefore there is nothing you can do on the server side to initiate this refresh. The only solution is to use client-side script to refresh the borwser.

Chad
Hi ola,

unfortunately a browser only supports the pull way. But maybe this article can be of help to you:Using IE's Web Service Behavior To Create Rich ASP.NET Applications. I know the next version of ASP.NET uses something like client call back functionality that's able to only update small portions of a page without refreshing the whole page.

Of course using this technique still requires to call a method on a time interval.

Grz, Kris.
Chad,

thank you very much for your reply.
I have additional question. When you refer to a client-side script that can be used to refresh a browser, are you talking about a separate program running on the same machine where the browser is open, or it is something incorporated into the web form code that does it on a timely bases? If it was a separate program (which could know which instance of the browser I need to refresh, which form on that instance of the browser is open and how to envoke the refresh on the browser), it would probably work for me. I will just need to find out how to do it (if at all it is possible). Do you know anything about it? Any ideas/suggestions?

Thank you

ola
ola,

I was actually talking about using a JavaScript timer or using the Meta tags to refresh the browser. I think it would be nearly impossible to write a Windows app to know which browser to refresh when. This would be way more work than it's worth. I think your only solution here is to just put code in your page to refresh the entire page every so often. Sorry I don't have the perfect solution for your problem.

Chad

Submitting the form correctly using the enter key

Hi all,

Simple problem:

I have a simple form and a submit and cancel image button underneath.

I also have a logout image button at the top of the page. This button is
rendered from a user control that is seperate from the form page itself.

At the moment if I press enter when inside a textbox the log out button is
activated. How can I make sure that the submit button is activated when the
user presses enter?

Many thanks all

Kind RegardsEnter activates the first submit button in the layout. See details at
http://www.allasp.net/enterkey.aspx

Can you place the logout button after the submit one?

Eliyahu

"thechaosengine" <sh856531@.microsofts_free_email_service.com> wrote in
message news:O5N%23amv9EHA.2996@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button is
> rendered from a user control that is seperate from the form page itself.
> At the moment if I press enter when inside a textbox the log out button is
> activated. How can I make sure that the submit button is activated when
the
> user presses enter?
> Many thanks all
> Kind Regards
thechaosengine wrote:
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button
> is rendered from a user control that is seperate from the form page
> itself.
> At the moment if I press enter when inside a textbox the log out
> button is activated. How can I make sure that the submit button is
> activated when the user presses enter?
> Many thanks all
> Kind Regards

You can capture the Enter key with JavaScript
to get the behavior you want:
http://dotnetjunkies.com/WebLog/dar...03/03/8374.aspx

--

Riki

Submitting the form correctly using the enter key

Hi all,
Simple problem:
I have a simple form and a submit and cancel image button underneath.
I also have a logout image button at the top of the page. This button is
rendered from a user control that is seperate from the form page itself.
At the moment if I press enter when inside a textbox the log out button is
activated. How can I make sure that the submit button is activated when the
user presses enter?
Many thanks all
Kind RegardsEnter activates the first submit button in the layout. See details at
http://www.allasp.net/enterkey.aspx
Can you place the logout button after the submit one?
Eliyahu
"thechaosengine" <sh856531@.microsofts_free_email_service.com> wrote in
message news:O5N%23amv9EHA.2996@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button is
> rendered from a user control that is seperate from the form page itself.
> At the moment if I press enter when inside a textbox the log out button is
> activated. How can I make sure that the submit button is activated when
the
> user presses enter?
> Many thanks all
> Kind Regards
>
thechaosengine wrote:
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button
> is rendered from a user control that is seperate from the form page
> itself.
> At the moment if I press enter when inside a textbox the log out
> button is activated. How can I make sure that the submit button is
> activated when the user presses enter?
> Many thanks all
> Kind Regards
You can capture the Enter key with JavaScript
to get the behavior you want:
http://dotnetjunkies.com/WebLog/dar...03/03/8374.aspx
Riki

Submitting seperate values from a checkbox list?

Hi there

does anyone have time to explain how to submit seperate values from my checkbox list?
I would be muchly appreciative.

so far I have the first boxes value returning, I realise it has to go in the if/foreach loop to make a value for each one but when I put my sql command in there it can't be recognized...

please help!!

-Matt

SqlCommand cmdInterest;

cmdInterest = new SqlCommand( "Insert tbl_interests ( interestID ) Values (@dotnet.itags.org.interestID) ", conform );

//check box item testing

foreach (ListItem itmInterest in chkl_interests.Items)
{

if (itmInterest.Selected){

//now I have no idea what to put here??

}
}

cmdInterest.Parameters.Add( "@dotnet.itags.org.interestID", chkl_interests.SelectedItem.Value );

conform.Open();

cmdInsert.ExecuteNonQuery();
cmdInterest.ExecuteNonQuery();

conform.Close();

You can store the variables's values in an array, and then submit it.

string[] names = new string[5];
int i = new int();

for each (ListItem itmInterest in chkl_interests.Items)

{

names[i] = chkl_interests.Items.tostring();
i++;
}

then in the pre-render event, just store the value before you submit it.

viewstate("names") = names;

to pass its value to the client do this:

response.write("<script language=""Javascript""> ")
response.write("var array[5]; ")
response.write("array = " + names + "; ")
response.write("</script>")

I dont know if this will help you, but i dont really know what do you want.

Submitting value from a hidden form field

I have a form inserting into an access database, 1 of the fields is hidden and required.
When I click submit the insert fails, if I change the visible value to "true" the insert succeeds.
I know this is probably really simple but I can't figure it out.If you set a controls visibility to false then it doesn't appear in the rendered HTML, therefore your hidden field won't be there at all (check the HTML source). In order to make a control still contain a value but be readonly try using the enabled property and set it to fale instead eg

<asp:TextBox id="myTextBox" enabled="false" runat="server"/>

That way the value is retained but it can't be changed.

Other option is to use a 'traditional' <input type="hidden"> field.
Thanks but the value has to be editable. The hidden field is actually receiving a date that is selected from a calendar on the page using this:


void Selection_Change(Object sender, EventArgs e)
{
countDate.Text = calendar.SelectedDate.ToShortDateString();
}

Where countDate is the hidden field.

If there is an easier way to do this please let me know.
As was explained,

you could use:

<input type="hidden"runat="server" ID="countDate"
Then just the code would be:


countDate.Value = calendar.SelectedDate.ToShortDateString();

Thanks, that worked.

I now have another problem, when changing the date on the calendar it appears to be trying to submit the form, causing error messages as some other fields are also required.

Submitting Using Javascript

Hi everyone,

My question is related to making a form submit using javascript. Here is my
scenario. I have a form, which includes a user control. The user control
has a search button and a submit button. I have visably hidden th search
button by setting its appearance and added an HTML button which calls the
click event of my real server control button.

This works fine.

I now want to cause the click event of the search button to be called when
the user hits the enter key in the text search text box. I have done this by
using the OnKeyDown event of the body tag and check if the character is the
enter key. This does invoke the function and I can do an alert('hello
world'); to prove it is working.

However . . . . . . .

If I try and call the real search button click() from this event nothing
happens.

Does anyone have insight into what I am doing wrong or how I can resolve it.

Many ThanksThis is probably a bug but for some reason asp.net doesn't sent the form
post variables to the web server if one textbox is on the page. So, calling
the button click() would actually post the form; but asp.net would not run
any server side processing since it has no clue on what control caused the
postback. There is a way around this. You can drop an extra textbox on the
page and hide it with css. If 2 textboxes are on the page then all the form
post variables will be sent along with the page and calling the click() on
the button would actually run the server side code. To hide the textbox you
can do something like this:

<asp:TextBox runat="server" style="display:hidden;visibility:none;" />

I hope this works.

"Goofy" <me@.mine.comwrote in message
news:eNZ#6Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi everyone,
>
My question is related to making a form submit using javascript. Here is
my scenario. I have a form, which includes a user control. The user
control has a search button and a submit button. I have visably hidden th
search button by setting its appearance and added an HTML button which
calls the click event of my real server control button.
>
This works fine.
>
I now want to cause the click event of the search button to be called when
the user hits the enter key in the text search text box. I have done this
by using the OnKeyDown event of the body tag and check if the character is
the enter key. This does invoke the function and I can do an alert('hello
world'); to prove it is working.
>
However . . . . . . .
>
If I try and call the real search button click() from this event nothing
happens.
>
Does anyone have insight into what I am doing wrong or how I can resolve
it.
>
Many Thanks
>
>
>
>
>


Having made this change, when the enter key is pressed the form is
submitted, but I dont want a default submission, I need it to be the
btnSearch

function OKD(){ if (window.event.keyCode == 13 )
{
MultiProjectPicker1_btnSearch.click();
event.returnValue=false;
event.cancel = true; }
}

"tdavisjr" <tdavisjr@.gmail.comwrote in message
news:%23PRIIZt7GHA.4408@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

This is probably a bug but for some reason asp.net doesn't sent the form
post variables to the web server if one textbox is on the page. So,
calling the button click() would actually post the form; but asp.net would
not run any server side processing since it has no clue on what control
caused the postback. There is a way around this. You can drop an extra
textbox on the page and hide it with css. If 2 textboxes are on the page
then all the form post variables will be sent along with the page and
calling the click() on the button would actually run the server side code.
To hide the textbox you can do something like this:
>
<asp:TextBox runat="server" style="display:hidden;visibility:none;" />
>
I hope this works.
>
"Goofy" <me@.mine.comwrote in message
news:eNZ#6Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>Hi everyone,
>>
>My question is related to making a form submit using javascript. Here is
>my scenario. I have a form, which includes a user control. The user
>control has a search button and a submit button. I have visably hidden th
>search button by setting its appearance and added an HTML button which
>calls the click event of my real server control button.
>>
>This works fine.
>>
>I now want to cause the click event of the search button to be called
>when the user hits the enter key in the text search text box. I have done
>this by using the OnKeyDown event of the body tag and check if the
>character is the enter key. This does invoke the function and I can do an
>alert('hello world'); to prove it is working.
>>
>However . . . . . . .
>>
>If I try and call the real search button click() from this event nothing
>happens.
>>
>Does anyone have insight into what I am doing wrong or how I can resolve
>it.
>>
>Many Thanks
>>
>>
>>
>>
>>


there are several possible problems.

1) you specified invisible for the button. this will cause the button to not
render, so there is nothing for javascript to call.

2) you are not using validation, so the button is a standard submit button.
in this case there is not a onclick routine to call.

a simple solution for what you want is to use onchange on the textbx and set
autopostback. then asp.net will generate javascript to postback.

-- bruce (sqlwork.com)

"Goofy" <me@.mine.comwrote in message
news:eNZ%236Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi everyone,
>
My question is related to making a form submit using javascript. Here is
my scenario. I have a form, which includes a user control. The user
control has a search button and a submit button. I have visably hidden th
search button by setting its appearance and added an HTML button which
calls the click event of my real server control button.
>
This works fine.
>
I now want to cause the click event of the search button to be called when
the user hits the enter key in the text search text box. I have done this
by using the OnKeyDown event of the body tag and check if the character is
the enter key. This does invoke the function and I can do an alert('hello
world'); to prove it is working.
>
However . . . . . . .
>
If I try and call the real search button click() from this event nothing
happens.
>
Does anyone have insight into what I am doing wrong or how I can resolve
it.
>
Many Thanks
>
>
>
>
>


Excellent

Just goes to show, the simple solution is easy once you know it. I never
thought to use AP on this, what a dummy I am.

Cheers

"bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.comwrote
in message news:ukVX54t7GHA.2384@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

there are several possible problems.
>
1) you specified invisible for the button. this will cause the button to
not render, so there is nothing for javascript to call.
>
2) you are not using validation, so the button is a standard submit
button. in this case there is not a onclick routine to call.
>
a simple solution for what you want is to use onchange on the textbx and
set autopostback. then asp.net will generate javascript to postback.
>
>
-- bruce (sqlwork.com)
>
>
>
>
"Goofy" <me@.mine.comwrote in message
news:eNZ%236Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>Hi everyone,
>>
>My question is related to making a form submit using javascript. Here is
>my scenario. I have a form, which includes a user control. The user
>control has a search button and a submit button. I have visably hidden th
>search button by setting its appearance and added an HTML button which
>calls the click event of my real server control button.
>>
>This works fine.
>>
>I now want to cause the click event of the search button to be called
>when the user hits the enter key in the text search text box. I have done
>this by using the OnKeyDown event of the body tag and check if the
>character is the enter key. This does invoke the function and I can do an
>alert('hello world'); to prove it is working.
>>
>However . . . . . . .
>>
>If I try and call the real search button click() from this event nothing
>happens.
>>
>Does anyone have insight into what I am doing wrong or how I can resolve
>it.
>>
>Many Thanks
>>
>>
>>
>>
>>


>
>

Submitting Using Javascript

Hi everyone,
My question is related to making a form submit using javascript. Here is my
scenario. I have a form, which includes a user control. The user control
has a search button and a submit button. I have visably hidden th search
button by setting its appearance and added an HTML button which calls the
click event of my real server control button.
This works fine.
I now want to cause the click event of the search button to be called when
the user hits the enter key in the text search text box. I have done this by
using the OnKeyDown event of the body tag and check if the character is the
enter key. This does invoke the function and I can do an alert('hello
world'); to prove it is working.
However . . . . . . .
If I try and call the real search button click() from this event nothing
happens.
Does anyone have insight into what I am doing wrong or how I can resolve it.
Many ThanksThis is probably a bug but for some reason asp.net doesn't sent the form
post variables to the web server if one textbox is on the page. So, calling
the button click() would actually post the form; but asp.net would not run
any server side processing since it has no clue on what control caused the
postback. There is a way around this. You can drop an extra textbox on the
page and hide it with css. If 2 textboxes are on the page then all the form
post variables will be sent along with the page and calling the click() on
the button would actually run the server side code. To hide the textbox you
can do something like this:
<asp:TextBox runat="server" style="display:hidden;visibility:none;" />
I hope this works.
"Goofy" <me@.mine.com> wrote in message
news:eNZ#6Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...
> Hi everyone,
> My question is related to making a form submit using javascript. Here is
> my scenario. I have a form, which includes a user control. The user
> control has a search button and a submit button. I have visably hidden th
> search button by setting its appearance and added an HTML button which
> calls the click event of my real server control button.
> This works fine.
> I now want to cause the click event of the search button to be called when
> the user hits the enter key in the text search text box. I have done this
> by using the OnKeyDown event of the body tag and check if the character is
> the enter key. This does invoke the function and I can do an alert('hello
> world'); to prove it is working.
> However . . . . . . .
> If I try and call the real search button click() from this event nothing
> happens.
> Does anyone have insight into what I am doing wrong or how I can resolve
> it.
> Many Thanks
>
>
>
Having made this change, when the enter key is pressed the form is
submitted, but I dont want a default submission, I need it to be the
btnSearch
function OKD(){ if (window.event.keyCode == 13 )
{
MultiProjectPicker1_btnSearch.click();
event.returnValue=false;
event.cancel = true; }
}
"tdavisjr" <tdavisjr@.gmail.com> wrote in message
news:%23PRIIZt7GHA.4408@.TK2MSFTNGP02.phx.gbl...
> This is probably a bug but for some reason asp.net doesn't sent the form
> post variables to the web server if one textbox is on the page. So,
> calling the button click() would actually post the form; but asp.net would
> not run any server side processing since it has no clue on what control
> caused the postback. There is a way around this. You can drop an extra
> textbox on the page and hide it with css. If 2 textboxes are on the page
> then all the form post variables will be sent along with the page and
> calling the click() on the button would actually run the server side code.
> To hide the textbox you can do something like this:
> <asp:TextBox runat="server" style="display:hidden;visibility:none;" />
> I hope this works.
> "Goofy" <me@.mine.com> wrote in message
> news:eNZ#6Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...
there are several possible problems.
1) you specified invisible for the button. this will cause the button to not
render, so there is nothing for javascript to call.
2) you are not using validation, so the button is a standard submit button.
in this case there is not a onclick routine to call.
a simple solution for what you want is to use onchange on the textbx and set
autopostback. then asp.net will generate javascript to postback.
-- bruce (sqlwork.com)
"Goofy" <me@.mine.com> wrote in message
news:eNZ%236Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...
> Hi everyone,
> My question is related to making a form submit using javascript. Here is
> my scenario. I have a form, which includes a user control. The user
> control has a search button and a submit button. I have visably hidden th
> search button by setting its appearance and added an HTML button which
> calls the click event of my real server control button.
> This works fine.
> I now want to cause the click event of the search button to be called when
> the user hits the enter key in the text search text box. I have done this
> by using the OnKeyDown event of the body tag and check if the character is
> the enter key. This does invoke the function and I can do an alert('hello
> world'); to prove it is working.
> However . . . . . . .
> If I try and call the real search button click() from this event nothing
> happens.
> Does anyone have insight into what I am doing wrong or how I can resolve
> it.
> Many Thanks
>
>
>
Excellent
Just goes to show, the simple solution is easy once you know it. I never
thought to use AP on this, what a dummy I am.
Cheers
"bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com> wrote
in message news:ukVX54t7GHA.2384@.TK2MSFTNGP04.phx.gbl...
> there are several possible problems.
> 1) you specified invisible for the button. this will cause the button to
> not render, so there is nothing for javascript to call.
> 2) you are not using validation, so the button is a standard submit
> button. in this case there is not a onclick routine to call.
> a simple solution for what you want is to use onchange on the textbx and
> set autopostback. then asp.net will generate javascript to postback.
>
> -- bruce (sqlwork.com)
>
>
> "Goofy" <me@.mine.com> wrote in message
> news:eNZ%236Jt7GHA.4288@.TK2MSFTNGP02.phx.gbl...
>

Submitting whole HTML document to Server

Is there a way to return the whole HTML document from the Client to
the Server "as is" so I can use ASP.NET to parse through it and look
for stuff?
I want to see what some client side JavaScript may have done to the
XHTML document."GMartin" <glenn.e.martin@.gmail.com> wrote in message
news:d9443226-88cf-4bb0-b1d6-4f9514c0ab02@.j20g2000hsi.googlegroups.com...
> Is there a way to return the whole HTML document from the Client to
> the Server "as is" so I can use ASP.NET to parse through it and look
> for stuff?
> I want to see what some client side JavaScript may have done to the
> XHTML document.
This doesn't directly answer your question, but it may be what you are
looking for.
http://projects.nikhilk.net/Projects/WebDevHelper.aspx
In addition to its many other features, it will show you the "live" HTML
source for a page (as modified by any javascript).
I'm looking to do it at runtime. Not with a utility while
programming.
On Feb 11, 1:31 pm, "Scott Roberts" <srobe...@.no.spam.here-webworks-
software.com> wrote:
> "GMartin" <glenn.e.mar...@.gmail.com> wrote in message
> news:d9443226-88cf-4bb0-b1d6-4f9514c0ab02@.j20g2000hsi.googlegroups.com...
>
>
> This doesn't directly answer your question, but it may be what you are
> looking for.
> http://projects.nikhilk.net/Projects/WebDevHelper.aspx
> In addition to its many other features, it will show you the "live" HTML
> source for a page (as modified by any javascript).

Subprocedure for Oracle's SET DEFINE OFF command

I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" command
in an Oracle database. I tried the following:
Public Shared Sub SetDefineOff()
Dim myconnection As New
OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
myconnection.Open()
cmdsetdefineoff.ExecuteNonQuery()
myconnection.Close()
End Sub
But I recieve the following error:
Server Error in '/lvbeporgtest' Application.
----
--
ORA-00922: missing or invalid option
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
missing or invalid option
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[OracleException: ORA-00922: missing or invalid option
]
System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
errorHandle, Int32 rc) +174
System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle,
CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle,
CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +32
System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
needRowid, OciHandle& rowidDescriptor) +170
System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +56
Global.SetDefineOff() in C:\Documents and Settings\Nathan
Sokalski\VSWebCache\www.webdevlccc.com\lvbeporgtest\Global.asax.vb:32
newmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
C:\Documents and Settings\Nathan
Sokalski\VSWebCache\[url]www.webdevlccc.com\lvbeporgtest\newmin.aspx.vb:71[/url]
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
eventArgument) +57
System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
----
--
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300
Can someone tell me what I am doing wrong or what is causing the error and
what I can do to fix it? Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/Hi Nathan,
I am no Oracle expert but I can tell you two things:
1. Your code is fine, you aren't doing anything wrong.
2. "SET DEFINE OFF" is not a SQL command, it is a SQL *Plus command. It
just won't work Oracle has no idea what you mean.
Tim
"Nathan Sokalski" wrote:

> I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" comman
d
> in an Oracle database. I tried the following:
> Public Shared Sub SetDefineOff()
> Dim myconnection As New
> OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
> Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
> myconnection.Open()
> cmdsetdefineoff.ExecuteNonQuery()
> myconnection.Close()
> End Sub
>
> But I recieve the following error:
> Server Error in '/lvbeporgtest' Application.
> ----
--
> ORA-00922: missing or invalid option
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
> missing or invalid option
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of the
> exception can be identified using the exception stack trace below.
> Stack Trace:
> [OracleException: ORA-00922: missing or invalid option
> ]
> System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
> errorHandle, Int32 rc) +174
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
> rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +
32
> System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
> needRowid, OciHandle& rowidDescriptor) +170
> System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +56
> Global.SetDefineOff() in C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\www.webdevlccc.com\lvbeporgtest\Global.asax.vb:32
> newmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
> C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\[url]www.webdevlccc.com\lvbeporgtest\newmin.aspx.vb:71[/url]
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Ra
isePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ----
--
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.N
ET
> Version:1.1.4322.2300
>
> Can someone tell me what I am doing wrong or what is causing the error and
> what I can do to fix it? Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>
>
I would recommend that rather than making this a separate command he
include this line at the beginning of whatever stored procedure on
Oracle that he wants to run.
Sort of like in a SQL procedure where you start with SET ANSI OFF.
timkling wrote:
> Hi Nathan,
> I am no Oracle expert but I can tell you two things:
> 1. Your code is fine, you aren't doing anything wrong.
> 2. "SET DEFINE OFF" is not a SQL command, it is a SQL *Plus command. It
> just won't work Oracle has no idea what you mean.
> Tim
> "Nathan Sokalski" wrote:
>
You might need to wrap the SET DEFINE OFF in a BEGIN/END block:
BEGIN SET DEFINE OFF; END;
I've not used Oracle for a couple of years so the syntax might not be correc
t.
"Nathan Sokalski" wrote:

> I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" comman
d
> in an Oracle database. I tried the following:
> Public Shared Sub SetDefineOff()
> Dim myconnection As New
> OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
> Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
> myconnection.Open()
> cmdsetdefineoff.ExecuteNonQuery()
> myconnection.Close()
> End Sub
>
> But I recieve the following error:
> Server Error in '/lvbeporgtest' Application.
> ----
--
> ORA-00922: missing or invalid option
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
> missing or invalid option
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of the
> exception can be identified using the exception stack trace below.
> Stack Trace:
> [OracleException: ORA-00922: missing or invalid option
> ]
> System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
> errorHandle, Int32 rc) +174
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
> rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +
32
> System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
> needRowid, OciHandle& rowidDescriptor) +170
> System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +56
> Global.SetDefineOff() in C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\www.webdevlccc.com\lvbeporgtest\Global.asax.vb:32
> newmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
> C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\[url]www.webdevlccc.com\lvbeporgtest\newmin.aspx.vb:71[/url]
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Ra
isePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ----
--
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.N
ET
> Version:1.1.4322.2300
>
> Can someone tell me what I am doing wrong or what is causing the error and
> what I can do to fix it? Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>
>