Saturday, March 31, 2012
submitting a PDF form
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
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 form from the Server Control
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 in csharp
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 HTML page data through form.
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 correctly using the enter key
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
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?
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
You can store the variables's values in an array, and then submit it.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();
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
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
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
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...
>
Thursday, March 22, 2012
suppressing Submit command with a Delete button
confirming whether the user wishes to really delete the item or not.
The confirm pops up, but I cannot suppress the submission when selecting
Cancel.
Heres what I have so far:
' adding the javascript call to the button:
Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItem.ItemCreated
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)
objDeleteButton.CssClass = "inputbutton"
objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
End If
End Sub
' client side code in javascript
function confirmDeleteItem()
{
if (confirm("Are you sure you wish to delete this item?"))
{
return true;
}
else
{
return false;
}
}
any help is appreciated. thank you.Sounds like you have validation controls on there, which causes the runtime
to emit yet another onClick handler which submits the form. Try using an
<input type="button"> instead of an <asp:button> control, and if you need
validation just script in the validation call (and, as always, make sure you
explicitly validate on the server, as client side validation is easy to
foil).
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in message
news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> I have a Delete button in my datagrid. I'm attempting to add some code
> confirming whether the user wishes to really delete the item or not.
> The confirm pops up, but I cannot suppress the submission when selecting
> Cancel.
> Heres what I have so far:
> ' adding the javascript call to the button:
> Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgItem.ItemCreated
> If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> ListItemType.AlternatingItem Then
> Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)
> objDeleteButton.CssClass = "inputbutton"
> objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> End If
> End Sub
>
> ' client side code in javascript
> function confirmDeleteItem()
> {
> if (confirm("Are you sure you wish to delete this item?"))
> {
> return true;
> }
> else
> {
> return false;
> }
> }
> any help is appreciated. thank you.
Chris:
Thanks for the reply. I am struggling with this.
If I take your approach it seems I dont have the ability to wire it to the
DeleteCommand event. This means I have to access the DataKey for the row
through the client, which I dont want to do. I could be wrong on this
though.
All I really want to do is have a DeleteCommand button that performs a
delete with a confirmation prior to deletion. My code does not have any
other validators on the page. There is another button on the page, but
performs a completely unrelated task.
"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> Sounds like you have validation controls on there, which causes the
runtime
> to emit yet another onClick handler which submits the form. Try using an
> <input type="button"> instead of an <asp:button> control, and if you need
> validation just script in the validation call (and, as always, make sure
you
> explicitly validate on the server, as client side validation is easy to
> foil).
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
> "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
message
> news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > I have a Delete button in my datagrid. I'm attempting to add some code
> > confirming whether the user wishes to really delete the item or not.
> > The confirm pops up, but I cannot suppress the submission when selecting
> > Cancel.
> > Heres what I have so far:
> > ' adding the javascript call to the button:
> > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> dgItem.ItemCreated
> > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > ListItemType.AlternatingItem Then
> > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
Button)
> > objDeleteButton.CssClass = "inputbutton"
> > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > End If
> > End Sub
> > ' client side code in javascript
> > function confirmDeleteItem()
> > {
> > if (confirm("Are you sure you wish to delete this item?"))
> > {
> > return true;
> > }
> > else
> > {
> > return false;
> > }
> > }
> > any help is appreciated. thank you.
Aha - that's a special case I hadn't considered.
Try this article:
http://authors.aspalliance.com/aldo...xamples/cd.aspx
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Elliot M. Rodriguez" <someemail> wrote in message
news:ucDxzLAxDHA.2460@.TK2MSFTNGP10.phx.gbl...
> Chris:
> Thanks for the reply. I am struggling with this.
> If I take your approach it seems I dont have the ability to wire it to the
> DeleteCommand event. This means I have to access the DataKey for the row
> through the client, which I dont want to do. I could be wrong on this
> though.
> All I really want to do is have a DeleteCommand button that performs a
> delete with a confirmation prior to deletion. My code does not have any
> other validators on the page. There is another button on the page, but
> performs a completely unrelated task.
>
> "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
> news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> > Sounds like you have validation controls on there, which causes the
> runtime
> > to emit yet another onClick handler which submits the form. Try using an
> > <input type="button"> instead of an <asp:button> control, and if you
need
> > validation just script in the validation call (and, as always, make sure
> you
> > explicitly validate on the server, as client side validation is easy to
> > foil).
> > --
> > Chris Jackson
> > Software Engineer
> > Microsoft MVP - Windows Client
> > Windows XP Associate Expert
> > --
> > More people read the newsgroups than read my email.
> > Reply to the newsgroup for a faster response.
> > (Control-G using Outlook Express)
> > --
> > "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
> message
> > news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > > I have a Delete button in my datagrid. I'm attempting to add some code
> > > confirming whether the user wishes to really delete the item or not.
> > > > The confirm pops up, but I cannot suppress the submission when
selecting
> > > Cancel.
> > > > Heres what I have so far:
> > > > ' adding the javascript call to the button:
> > > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> > dgItem.ItemCreated
> > > > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > > ListItemType.AlternatingItem Then
> > > > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
> Button)
> > > > objDeleteButton.CssClass = "inputbutton"
> > > > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > > > End If
> > > > End Sub
> > > > > > ' client side code in javascript
> > > > function confirmDeleteItem()
> > > > {
> > > > if (confirm("Are you sure you wish to delete this item?"))
> > > > {
> > > > return true;
> > > > }
> > > > else
> > > > {
> > > > return false;
> > > > }
> > > > }
> > > > any help is appreciated. thank you.
> >
Chris:
I realized I forgot the lousy "return" keyword in Attributes.Add lol...
Thanks for the article and the help.
"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:OwfPeBBxDHA.1196@.TK2MSFTNGP12.phx.gbl...
> Aha - that's a special case I hadn't considered.
> Try this article:
> http://authors.aspalliance.com/aldo...xamples/cd.aspx
>
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
> "Elliot M. Rodriguez" <someemail> wrote in message
> news:ucDxzLAxDHA.2460@.TK2MSFTNGP10.phx.gbl...
> > Chris:
> > Thanks for the reply. I am struggling with this.
> > If I take your approach it seems I dont have the ability to wire it to
the
> > DeleteCommand event. This means I have to access the DataKey for the row
> > through the client, which I dont want to do. I could be wrong on this
> > though.
> > All I really want to do is have a DeleteCommand button that performs a
> > delete with a confirmation prior to deletion. My code does not have any
> > other validators on the page. There is another button on the page, but
> > performs a completely unrelated task.
> > "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
> > news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> > > Sounds like you have validation controls on there, which causes the
> > runtime
> > > to emit yet another onClick handler which submits the form. Try using
an
> > > <input type="button"> instead of an <asp:button> control, and if you
> need
> > > validation just script in the validation call (and, as always, make
sure
> > you
> > > explicitly validate on the server, as client side validation is easy
to
> > > foil).
> > > > --
> > > Chris Jackson
> > > Software Engineer
> > > Microsoft MVP - Windows Client
> > > Windows XP Associate Expert
> > > --
> > > More people read the newsgroups than read my email.
> > > Reply to the newsgroup for a faster response.
> > > (Control-G using Outlook Express)
> > > --
> > > > "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
> > message
> > > news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > > > I have a Delete button in my datagrid. I'm attempting to add some
code
> > > > confirming whether the user wishes to really delete the item or not.
> > > > > > The confirm pops up, but I cannot suppress the submission when
> selecting
> > > > Cancel.
> > > > > > Heres what I have so far:
> > > > > > ' adding the javascript call to the button:
> > > > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> > > dgItem.ItemCreated
> > > > > > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > > > ListItemType.AlternatingItem Then
> > > > > > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
> > Button)
> > > > > > objDeleteButton.CssClass = "inputbutton"
> > > > > > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > > > > > End If
> > > > > > End Sub
> > > > > > > > > > ' client side code in javascript
> > > > > > function confirmDeleteItem()
> > > > > > {
> > > > > > if (confirm("Are you sure you wish to delete this item?"))
> > > > > > {
> > > > > > return true;
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > return false;
> > > > > > }
> > > > > > }
> > > > > > any help is appreciated. thank you.
> > > > > >