Monday, March 26, 2012
oh no! another datagrid dropdown question!
I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
to create my dropdown list from a database. The DDL gets populated! The
artical says, "then set the index as you normally would". Well, what can i
say i can't figure out how to set it.
any ideas would be great!
thanks
kesi guess i need to know where to set the selectedindex as well as how.
thanks
kes
"Kurt Schroeder" wrote:
> I'm getting there!!!!
> I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
> to create my dropdown list from a database. The DDL gets populated! The
> artical says, "then set the index as you normally would". Well, what can i
> say i can't figure out how to set it.
> any ideas would be great!
> thanks
> kes
You set the index like this:
dropdown.SelectedIndex = 0; // or whatever value you want 1,2,3.
"Kurt Schroeder" wrote:
> I'm getting there!!!!
> I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
> to create my dropdown list from a database. The DDL gets populated! The
> artical says, "then set the index as you normally would". Well, what can i
> say i can't figure out how to set it.
> any ideas would be great!
> thanks
> kes
thanks for answering.
that will not work because the dropdown list is a child control of the
datagrid. I tried it and i gives me a run time error. even afteri manuelly
decoarred it a protected with events...
but thanks! and please let me know if i'm wrong about this!
kes
"Tu-Thach" wrote:
> You set the index like this:
> dropdown.SelectedIndex = 0; // or whatever value you want 1,2,3.
> "Kurt Schroeder" wrote:
>
How did you get a hold of the DropDownList? Did you use the FindControl
method?
"Kurt Schroeder" wrote:
> thanks for answering.
> that will not work because the dropdown list is a child control of the
> datagrid. I tried it and i gives me a run time error. even afteri manuelly
> decoarred it a protected with events...
> but thanks! and please let me know if i'm wrong about this!
> kes
> "Tu-Thach" wrote:
>
i have it figured out now, thanks.
kes
"Tu-Thach" wrote:
> How did you get a hold of the DropDownList? Did you use the FindControl
> method?
> "Kurt Schroeder" wrote:
>
oh no! another datagrid dropdown question!
I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
to create my dropdown list from a database. The DDL gets populated! The
artical says, "then set the index as you normally would". Well, what can i
say i can't figure out how to set it.
any ideas would be great!
thanks
kesi guess i need to know where to set the selectedindex as well as how.
thanks
kes
"Kurt Schroeder" wrote:
> I'm getting there!!!!
> I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
> to create my dropdown list from a database. The DDL gets populated! The
> artical says, "then set the index as you normally would". Well, what can i
> say i can't figure out how to set it.
> any ideas would be great!
> thanks
> kes
You set the index like this:
dropdown.SelectedIndex = 0; // or whatever value you want 1,2,3.
"Kurt Schroeder" wrote:
> I'm getting there!!!!
> I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
> to create my dropdown list from a database. The DDL gets populated! The
> artical says, "then set the index as you normally would". Well, what can i
> say i can't figure out how to set it.
> any ideas would be great!
> thanks
> kes
thanks for answering.
that will not work because the dropdown list is a child control of the
datagrid. I tried it and i gives me a run time error. even afteri manuelly
decoarred it a protected with events...
but thanks! and please let me know if i'm wrong about this!
kes
"Tu-Thach" wrote:
> You set the index like this:
> dropdown.SelectedIndex = 0; // or whatever value you want 1,2,3.
> "Kurt Schroeder" wrote:
> > I'm getting there!!!!
> > I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
> > to create my dropdown list from a database. The DDL gets populated! The
> > artical says, "then set the index as you normally would". Well, what can i
> > say i can't figure out how to set it.
> > any ideas would be great!
> > thanks
> > kes
How did you get a hold of the DropDownList? Did you use the FindControl
method?
"Kurt Schroeder" wrote:
> thanks for answering.
> that will not work because the dropdown list is a child control of the
> datagrid. I tried it and i gives me a run time error. even afteri manuelly
> decoarred it a protected with events...
> but thanks! and please let me know if i'm wrong about this!
> kes
> "Tu-Thach" wrote:
> > You set the index like this:
> > dropdown.SelectedIndex = 0; // or whatever value you want 1,2,3.
> > "Kurt Schroeder" wrote:
> > > I'm getting there!!!!
> > > I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
> > > to create my dropdown list from a database. The DDL gets populated! The
> > > artical says, "then set the index as you normally would". Well, what can i
> > > say i can't figure out how to set it.
> > > any ideas would be great!
> > > thanks
> > > kes
i have it figured out now, thanks.
kes
"Tu-Thach" wrote:
> How did you get a hold of the DropDownList? Did you use the FindControl
> method?
> "Kurt Schroeder" wrote:
> > thanks for answering.
> > that will not work because the dropdown list is a child control of the
> > datagrid. I tried it and i gives me a run time error. even afteri manuelly
> > decoarred it a protected with events...
> > but thanks! and please let me know if i'm wrong about this!
> > kes
> > "Tu-Thach" wrote:
> > > You set the index like this:
> > > > dropdown.SelectedIndex = 0; // or whatever value you want 1,2,3.
> > > > "Kurt Schroeder" wrote:
> > > > > I'm getting there!!!!
> > > > I've used the artical http://www.4guysfromrolla.com/webtech/050801-1.shtml
> > > > to create my dropdown list from a database. The DDL gets populated! The
> > > > artical says, "then set the index as you normally would". Well, what can i
> > > > say i can't figure out how to set it.
> > > > any ideas would be great!
> > > > thanks
> > > > kes
Friday, March 16, 2012
On button click call javascript function before submit to server
I'm using javascript to validate my form on the client. But have a datagrid which I can add rows to, trouble is when I click the add row button it submits the form and my validation runs, I've got a function to clear the vaildation script but can't work out how to call it before the form submits does anyone have any ideas?
I've tried this but it bombs saying -
Compiler Error Message: BC30456: 'javascript' is not a member of 'ASP.submission_aspx'.
<asp:button id="cmdAddAuthor" runat="server" CausesValidation="False" OnClick="javascript:frmvalidator.clearAllValidations();" Text="Add"></asp:button>
The crux of the problem is how to call a javascript function before submit to the server for a specific button?
Cheers Alin your Page_Load event for the aspx page, try to add code like
cmdAddAuthor.Attributes.Add("onClick", "javascript:frmvalidator.clearAllValidations();")
kleinma,
Thanks, that is spot on, except my function doesn't seem to be working. I changed the javascript to an alert which works so your snippet was perfect.
Me.cmdAddAuthor.Attributes.Add("onClick", "javascript:alert('hello');")
Thanks a bunch
well if your function doesn't seem to be working then the problem lies within the code of clearAllValidations.. but once you get that sorted, everything should be fine ;)
if you want to post the function, I or someone else can try to help
Matt,
Thanks I've managed to get it sorted thanks for your help.
Cheers Al
sounds good.. just to give you a little insight on what is going on, the <asp:button> tag tells the aspx page that its an asp control that will be rendered as an HTML button when the server processes the page and spits HTML out to the browser. this is why you cant just stick your JS inline with the button. The code I provided tells the server to add that HTML to the control when its written out to the browser, hence giving the onclick functionality to the HTML control.
Matt,
Thanks, I appreciate the explanation. I'm still trying to get to grips with this beast. It's been a pretty steep learning curve over the last couple of months, but things are looking up as I'm starting to find that I can answer the occasional post.
Cheers Al
It takes time, but once you get the hang of all the "behind the scenes" stuff (which I am still doing myself, as I only do a little asp.net and mostly windows apps) it really gets easy and it is super powerful for a web development language
Yes, at some point it becomes Tetris-like.
Once you have the basics of the language and the way things work, the rest will start falling in to place. The occasion piece might not seem to fit right, but with time and practice, that happens less and less often.
on Post Back send page to top
I have to scroll down the webpage to find the navigation, then on postback the page is changed and stuck at the bottom of the next data results pageHi,
...and stuck at the bottom of the next data results page. Strange, that's just what most people are asking for.
Do you have smartnavigation set to true? This can make it possible to hold the scrolling position. So first check this (it can be set on the page or in the web.config).
Grz, Kris.
Yep! it was enabled, but not now.
Now im back to the top :)
Thanks