Showing posts with label building. Show all posts
Showing posts with label building. Show all posts

Saturday, March 31, 2012

Submitting form with multiple onclick events

Hi

I'm building a custom control which basically takes data from the user
and then submits it. I would use the validator controls but if I
understand correctly (I've been working with .Net for 2 weeks) you
cant 'embed' them in the custom controls. Someone correct me if I'm
wrong (and please point to an example :) )

So, to get around this, I'm using Javascript. In my control, I'm doing

Writer.WriteAttribute("OnClick", "javascript:checkData();" &
Page.GetPostBackEventReference(Me, "Data"))

for an Input item so I get something like

<input type="button" value="Submit"
OnClick="javascript:checkData();__doPostBack('MyControl','D ata')" /
The checkData() function does this:

function checkLogin()
{
if (document.Data.item1.value == "" )
{
alert("Please enter item 1.");
return false;
}

if (document.Data.item2.value == "" )
{
alert("Please enter item 2.");
return false;
}

if (document.Data.item1.value != "" && document.Data.item2.value !=
"" )
{
return true;
}

}

My query is, how do I get the click event to fire correctly so that i
get alerts when there is a problem, and it passes through and submits
the form if there isnt a problem?

Thanks

SamHi,

Your client side script should use cancelBubble and returnValue to
disable event default process and raise alert if error found.

function CallServer()
{
if validate
{
__doPostBack('MyControl','Data');
}
else
{
alert("Error");
window.event.cancelBubble = true;
window.event.returnValue = false;
}
}

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Natty Gur <natty@.dao2com.com> wrote in message news:<uSSwHLhAEHA.3348@.TK2MSFTNGP11.phx.gbl>...
> Hi,
> Your client side script should use cancelBubble and returnValue to
> disable event default process and raise alert if error found.
> function CallServer()
> {
> if validate
> {
> __doPostBack('MyControl','Data');
> }
> else
> {
> alert("Error");
> window.event.cancelBubble = true;
> window.event.returnValue = false;
> }
> }
>
> HTH
> Natty Gur[MVP]
> blog : http://weblogs.asp.net/ngur
> Mobile: +972-(0)58-888377
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Thanks Natty

This means I have to create inline javascripts which I'd rather not do
if I can help it. Just as luck would have it, after spending an 'hour
or two' trying to find a solution before posting, 5 mins after posting
I find a solution :( Always the way...

Anyhow, just for reference purposes, what I've done is to validate on
OnMouseDown and postback on OnClick. Works a treat
Hi Samuel,

Its unfortunate that you had to rework validation because of some incorrect
information about validators. The ASP.NET validators work fine within custom
controls. They have one key limitation related to their "location": the
ControlToValidate must be associated with the ID of a control in the same
"naming container". If your custom control impliments INamingContainer,
ControlToValidate can only point to other controls within your custom
control. If not, it can refer to other controls in the same naming container
that your custom control appears. Some types of naming containers: Page,
UserControl, and rows in DataGrid and DataList.

If you wanted to support validation without naming container limits, I wrote
a replacement to Microsoft's validators that overcomes that limitation among
numerous others: Professional Validation And More.
http://www.peterblum.com/vam/home.aspx.

-- Peter Blum
www.PeterBlum.com
Email: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Samuel Hon" <noreply@.samuelhon.co.uk> wrote in message
news:c8672b7d.0403040703.c458604@.posting.google.co m...
> Hi
> I'm building a custom control which basically takes data from the user
> and then submits it. I would use the validator controls but if I
> understand correctly (I've been working with .Net for 2 weeks) you
> cant 'embed' them in the custom controls. Someone correct me if I'm
> wrong (and please point to an example :) )
> So, to get around this, I'm using Javascript. In my control, I'm doing
> Writer.WriteAttribute("OnClick", "javascript:checkData();" &
> Page.GetPostBackEventReference(Me, "Data"))
> for an Input item so I get something like
> <input type="button" value="Submit"
> OnClick="javascript:checkData();__doPostBack('MyControl','D ata')" />
> The checkData() function does this:
> function checkLogin()
> {
> if (document.Data.item1.value == "" )
> {
> alert("Please enter item 1.");
> return false;
> }
> if (document.Data.item2.value == "" )
> {
> alert("Please enter item 2.");
> return false;
> }
> if (document.Data.item1.value != "" && document.Data.item2.value !=
> "" )
> {
> return true;
> }
> }
> My query is, how do I get the click event to fire correctly so that i
> get alerts when there is a problem, and it passes through and submits
> the form if there isnt a problem?
> Thanks
> Sam
"Peter Blum" <PLBlum@.Blum.info> wrote in message news:<OC#ZP$uAEHA.624@.TK2MSFTNGP10.phx.gbl>...
> Hi Samuel,
> Its unfortunate that you had to rework validation because of some incorrect
> information about validators. The ASP.NET validators work fine within custom
> controls. They have one key limitation related to their "location": the
> ControlToValidate must be associated with the ID of a control in the same
> "naming container". If your custom control impliments INamingContainer,
> ControlToValidate can only point to other controls within your custom
> control. If not, it can refer to other controls in the same naming container
> that your custom control appears. Some types of naming containers: Page,
> UserControl, and rows in DataGrid and DataList.
> If you wanted to support validation without naming container limits, I wrote
> a replacement to Microsoft's validators that overcomes that limitation among
> numerous others: Professional Validation And More.
> http://www.peterblum.com/vam/home.aspx.
> -- Peter Blum
> www.PeterBlum.com
> Email: PLBlum@.PeterBlum.com
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
<snip
Thanks Peter for clearing that up, I will re-investigate

Sam

Subscription website software in ASP.NET C#

Looking for an all-in-one solution for building and managing subscription or member's only web sites in ASP.NET C#. A quick scope of features are the ability to bill monthly to our subscribers via real-time credit card processing, posting content features (news, articles, blogs, etc), manage subscribers, shopping cart, discussion groups, RSS, flexible searching (tags, etc..) and basic reports.

Any ideas and comments welcomed.

Thanks,
Gio

Look to Sharepoint. Most the things are inbuilt in this. Its a Microsoft Product. Click try to search Sharepoint at msdn.microsoft.com or google.

Monday, March 26, 2012

Suggestions for a good forum tutorial asp.net + vb

I am building a forum site which will do all the usual things; threaded discussion, profile page etc. Can anyone point me to a good tutorial or provide some sound advice?

I will be developing in asp.net, VB, SQL Server and XML

Duke

You might start by examining some of the code in the starter kits that have forums. There are several open source forums with code available as well.

Jeff


Thanks for the speedy reply Jeff. On hind-sight this post should have been in the beginners section, but you live and learnSmile

I'll check the starter kits out now

Thursday, March 22, 2012

Support for generating random passwords in ASP.NET

Hi,
I am building web in ASP.NET using VB.NET to code the pages. I want to gene
rate random passwords for users. I know that password hashing is built right
into the .NET Framework. I was wondering if there is any built-in support f
or generating random passwo
rds in .Net. If the support is built-in, can you show me how to do it.
Thanks,
JoeThere is no random password functionality built into .NET.
But there is the Math.Random namespace that could easily help you string
together some random characters.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Joe" <Joe@.discussions.microsoft.com> wrote in message
news:C6413BC5-1DF5-4C8D-ADC2-BCEB6BBAB5F8@.microsoft.com...
> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to
generate random passwords for users. I know that password hashing is built
right into the .NET Framework. I was wondering if there is any built-in
support for generating random passwords in .Net. If the support is
built-in, can you show me how to do it.
> Thanks,
> Joe
>
Joe
Try this.. http://www.4guysfromrolla.com/webte...t011100-1.shtml
It's ASP rather than .NET, but shouldn't take too much conversion.
HTH
Dan
"Joe" wrote:

> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to generate r
andom passwords for users. I know that password hashing is built right into the .NET
Framework. I was wondering if there is any built-in support for generating random p
ass
words in .Net. If the support is built-in, can you show me how to do it.
> Thanks,
> Joe
>

Support for generating random passwords in ASP.NET

Hi,

I am building web in ASP.NET using VB.NET to code the pages. I want to generate random passwords for users. I know that password hashing is built right into the .NET Framework. I was wondering if there is any built-in support for generating random passwords in .Net. If the support is built-in, can you show me how to do it.

Thanks,

JoeThere is no random password functionality built into .NET.
But there is the Math.Random namespace that could easily help you string
together some random characters.

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

"Joe" <Joe@.discussions.microsoft.com> wrote in message
news:C6413BC5-1DF5-4C8D-ADC2-BCEB6BBAB5F8@.microsoft.com...
> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to
generate random passwords for users. I know that password hashing is built
right into the .NET Framework. I was wondering if there is any built-in
support for generating random passwords in .Net. If the support is
built-in, can you show me how to do it.
> Thanks,
> Joe
Joe

Try this.. http://www.4guysfromrolla.com/webte...t011100-1.shtml

It's ASP rather than .NET, but shouldn't take too much conversion.

HTH

Dan

"Joe" wrote:

> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to generate random passwords for users. I know that password hashing is built right into the .NET Framework. I was wondering if there is any built-in support for generating random passwords in .Net. If the support is built-in, can you show me how to do it.
> Thanks,
> Joe