Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Browser event from webform control

Reply
Thread Tools

Browser event from webform control

 
 
=?Utf-8?B?QXJuZQ==?=
Guest
Posts: n/a
 
      05-27-2004
How do I make a web form control react to a client side event in the browser
THe onclick event to server based. I am looking for onclick event on the client
I need something like this from a webform button control
<input type=button onclick="return OK()>"><script language="javascript"
function OK(

return confirm("Delete News Item. OK?")

</script
But I need the server event also.
 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      05-27-2004
Here's some server side code that outputs javascript similar to what you are
requesting:
myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Arne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How do I make a web form control react to a client side event in the

browser.
> THe onclick event to server based. I am looking for onclick event on the

client.
> I need something like this from a webform button control:
> <input type=button onclick="return OK()>"><script language="javascript">
> function OK()
> {
> return confirm("Delete News Item. OK?");
> }
> </script>
> But I need the server event also.



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      05-27-2004
Let's say your button tag looks like this:

<asp:button id="Button1" style="Z-INDEX: 103; LEFT: 62px; POSITION: absolute; TOP: 233px" runat="server"
Text="Do It"></asp:button>

Add the following line in the Page_Load procedure:

Button1.Attributes("OnClick") = "return OK();"

HTH
 
Reply With Quote
 
Vidar Petursson
Guest
Posts: n/a
 
      05-28-2004
Hi

Since you are using a regular button ( not submit )

myBtn.Attributes.Add("onclick","confirmDel(" + iItemID + ")");

Client
function confirmDel(iItemID){
if(confirm("Delete item?")) location.replace("pageToGo.aspx?iItemID=" +
iItemID);
// Or if you want submit the form
//if(confirm("Delete item?")) document.forms[0].submit();
}

If you use submit/ image button just return true/false
function confirmDel(){
return confirm("Delete item?");
}

--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/ ( IE 5.5+ only )

No matter where you go there you are
==============================
"Arne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How do I make a web form control react to a client side event in the
> browser.
> THe onclick event to server based. I am looking for onclick event on the
> client.
> I need something like this from a webform button control:
> <input type=button onclick="return OK()>"><script language="javascript">
> function OK()
> {
> return confirm("Delete News Item. OK?");
> }
> </script>
> But I need the server event also.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Another webform without closing the current webform ? Luqman ASP .Net 2 04-11-2007 02:43 AM
Moving value from popup Webform to main Webform? =?Utf-8?B?Vk1J?= ASP .Net 1 10-09-2006 05:15 PM
Using one webform to set a value on another webform =?Utf-8?B?bXN1aw==?= ASP .Net 1 07-12-2006 07:23 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Including WebForm Image Control in a Webform Table Control titof ASP .Net 0 07-24-2003 01:01 PM



Advertisments