S
Samuel Hon
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','Data')" />
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
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','Data')" />
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