Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > postback when enter key?

Reply
Thread Tools

postback when enter key?

 
 
jobs
Guest
Posts: n/a
 
      07-15-2007
asp.net 2.0.

I've got a web form when focused on a certain textboxes and i hit
enter, I want the page to postback to a particular event where I can
test textbox values.

I've tried a hidden default button with an event tied to it.. did not
work.

I've tried setting useSubmitBehavior on the button.



<form defaultfocus="TextBox_Search1" defaultbutton="Submit"
id="form1" runat="server">

<asp:TextBox ID="TextBox_Search1" runat="server" Width="214px"></
asp:TextBox>

<asp:Button ID="Submit" UseSubmitBehavior="True" Visible="False"
runat="server" Text="Button" />


Protected Sub Submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Submit.Click
If TextBox_Search1.Text <> "" Then
TitleSearch()
End If
End Sub

I've tried settign autopostpack on the textboxes, but then it post
when any change is made to the textbox and I tab around.

Thanks for any help or information.

 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      07-15-2007
"jobs" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...

> I've tried a hidden default button with an event tied to it.. did not
> work.


That's right - when you set a webcontrol's Visible property to "false", it
doesn't even get rendered to the client...

> I've tried setting useSubmitBehavior on the button.


See above...

> <asp:Button ID="Submit" UseSubmitBehavior="True" Visible="False"
> runat="server" Text="Button" />


<asp:Button ID="Submit" runat="server" Text="Button" OnClick="Submit_Click"
/>


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
 
 
 
jobs
Guest
Posts: n/a
 
      07-15-2007
Thanks. makes sense. Any way to tie the enter key to any other
control. I have an asp.menu 2.0 in that form. It would be great if
ENTER defaulted as a click to one of the menu items. possible?

I'll need to research, but if you know off hand, possible to set a
menu item to visible = false in the codebehind?

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      07-16-2007
"jobs" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...

> Thanks. makes sense. Any way to tie the enter key to any other
> control. I have an asp.menu 2.0 in that form. It would be great if
> ENTER defaulted as a click to one of the menu items. possible?


Not using the "wired-up" method, as that only supports buttons...

> I'll need to research, but if you know off hand, possible to set a
> menu item to visible = false in the codebehind?


MenuItems don't have a Visible property - however:

MyMenu.Items.Remove(MyMenu.FindItem("Customers"));

or

MyMenu.FindItem("Customers").ChildItems.Remove At(1);


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
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
hitting enter or shift+enter in asp.net designer messes up html code? Sunfire ASP .Net 2 11-06-2007 02:44 PM
How to disable imagebutton postback when i enter "enter" =?Utf-8?B?am9l?= ASP .Net 0 09-28-2006 06:46 AM
capturing from text area Shft+Enter, Control+Enter, Alt+Enter and browser issue. HopfZ Javascript 0 08-28-2006 10:11 AM
Enter Key H*ll, control enter key submit button BrianDH ASP .Net Web Controls 3 01-12-2005 08:29 PM
trigger HTML button by enter ENTER key Matt Javascript 1 03-06-2004 07:01 PM



Advertisments