Showing posts with label server side. Show all posts
Showing posts with label server side. Show all posts

Tuesday, August 31, 2010

Textbox validate characters digits only - Desktop App

I wanted to let the user enter onlydigits in a Textbox and validate the characters when the types.
I came up with this:





private void numericUpDown_Count_KeyPress(object sender, KeyPressEventArgs e)
{
if ("1234567890".IndexOf(e.KeyChar.ToString()) > 0)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}





tell me if there's an easier way :)

Monday, September 1, 2008

Calling a server side from client's Javascript

Did you ever need something like calling a server side thing from client's? Javascript ... ?

I think this is an easy way of doing that:





Response.Write ( " < script language="javascript"> function SetPmoR_Id() { document.all('" + lkbPmoRepAdd.ClientID + "').click(); } < / script>")

//or:

ClientScript.RegisterClientScriptBlock(this.GetType(), "somethn", " < script type='text/javascript'> function whatdoyouwannacalit() { try {document.all('" + yourlinkbutton.ClientID + "').click();} catch(e){} } < / script>");






what do you think?

you think there's an easier way? comment!