Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onsubmit and coditional formatting

Status
Not open for further replies.

techninut

Technical User
Nov 28, 2001
92
US
Hello newbie here so sorry if this seems a bit remedial.

anyways, I have an input box that displays data once you push the little submit button, however if you put data in the input box and hit enter it comes up blank, I know this is because the user is not pushing the on submit button but I was wondering if there was a way to execute the querey from either clicking the submit button like it already does, but also if the user just hits enter I want it to submit the data into my querey and execute.

question 2.

Is there a way to format the datagrid based on the results of my querey ? Like if I enter something into my input box and the results of the querey match a certain parameter I want it to highlight or possibly change the background color of the grid that results ? I am able to do this in Crystal Reports so I figured it would be possible in this as well .

thanks,

T
 
Q1:
here's how i do this for asp.net server controls...

use javascript function...
Code:
function setEnterKey(btnName) {
 if (event.keyCode == 13) {
   event.cancelBubble = true;
   event.returnValue = false;
   document.getElementById(btnName).click();
 }
}
and vb code...

Code:
txtA.Attributes.Add("onkeypress", "setEnterKey('btnA');")

Q2:

You can do conditional formatting based on things...usually I do this on the ItemDataBound event...you'd have to give more details to truly get a 'how to' response...


"...we both know I'm training to become a cagefigher...see what happens if you try 'n hit me..."
 
checkai,
Doesn't asp.net automatically submit the first asp:Button in a page when the Enter button is pressed?
Something I consider a bug myself.
I am assuming that techninut is using an html submit with no runat="server" and not an asp:Button.
Marty
 
my technique uses an asp:Button...works great too!!

"...we both know I'm training to become a cagefigher...see what happens if you try 'n hit me..."
 
my technique uses an asp:Button...works great too!!
That doesn't help if Marty's assumption is correct...

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
It is a button I used from the web forms panel under toolbox in Visual Studio.

Hey Chekai, where on the aspx page in VS can I enter the Javascript ? Sorry but like I said I am new to this environment.

T
 
where on the aspx page in VS can I enter the Javascript ?
In a javascript code block in the <head> tag just like you would do in HTML...

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
In your .aspx page

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
i usually put that in the page load...

Code:
if not page.ispostback then
   'add attributes here...
end if


ca8msm said:
That doesn't help if Marty's assumption is correct...
i think you may have misread...

"...we both know I'm training to become a cagefigher...see what happens if you try 'n hit me..."
 
i usually put that in the page load...
He's asking where to put the javascript code. If it isn't going to be dynamically created you may as well put in in the HTML as that is where it where it will be ran from.
i think you may have misread...
Why?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Ok. I guess what I should be asking then is where in Visual studio can I view the html for my .aspx page ?

T
 
nevermind, I found it. I will try the code and see if that works thanks.

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top