enter key hell problem 2

G

gh0st54

Hi me again

problem 2

on pages that have no user controls i want to submit using the enter key

i register
Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");

when i press enter it doesn't fire

what am i missing ???
 
S

Steve C. Orr [MVP, MCSD]

G

gh0st54

Sorry
I tried it but doesn't work

i'm being sent back to index.aspx ??? weird

so what i do know is

if(!Page.IsPostBack)
{
bla bla bla .....
Page.RegisterHiddenField("__EVENTTARGET","submit" );

this.txtSendTo.Attributes.Add("onFocus","javascript:SetTarget('submit');");
this.txtSubject.Attributes.Add("onFocus","javascript:SetTarget('submit');");
this.txtMessage.Attributes.Add("onFocus","javascript:SetTarget('notsubmit');");
}

if(Page.IsPostBack){
if(Page.Request.Form["__EVENTTARGET"].ToString().ToLower()=="submit"){
this.Send();
}
}

I know it's ugly but it works.

there has to be something not that ugly
 
G

Girish bharadwaj

have you checked out Scott's blog here:
http://www.hanselman.com/blog/PermaLink.aspx?guid=3f96f2ee-331f-480a-81af-dd62c8f92c23

That covers a few of them.


--
Girish Bharadwaj
http://msmvps.com/gbvb
gh0st54 said:
Sorry
I tried it but doesn't work

i'm being sent back to index.aspx ??? weird

so what i do know is

if(!Page.IsPostBack)
{
bla bla bla .....
Page.RegisterHiddenField("__EVENTTARGET","submit" );

this.txtSendTo.Attributes.Add("onFocus","javascript:SetTarget('submit');");this.txtSubject.Attributes.Add("onFocus","javascript:SetTarget('submit');");this.txtMessage.Attributes.Add("onFocus","javascript:SetTarget('notsubmit');
");
}

if(Page.IsPostBack){
if(Page.Request.Form["__EVENTTARGET"].ToString().ToLower()=="submit"){
this.Send();
}
}

I know it's ugly but it works.

there has to be something not that ugly


Matt Berther <[email protected]> wrote in message
Hello (e-mail address removed),

I've had a post that discusses how to accomplish this on my website:

http://www.mattberther.com/2003/06/000125.html
 
G

gh0st54

an other i noticed

i tried the following script :

function document.onkeydown(){
if(event.keycode==13){
event.returnvalue = false;
event.cancel=true;
//form.submit;
}
}

to block the postback to the page but it still posts back and i get
redirected to the index page

shouldn't this script prevent postback ??

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top