|
Suggested change should be done in OnClientClick Event
<asp:Button ID="Button1" runat="server" Text="Button"
OnClientClick='checkValue2(forms[0].TextBox1)' />
|
|
|
|
|
I have placed it in my code as following
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" runat="server">
var TextID="<%TextBox1.ClientID")";
function checkValue2()
{
Var ClientTextID= document.getElementByID(TextID);
if(ClientTextID.value='')
{
alert('text box is null);
}
else
{
alert('text box is not null);
}
}
</script>
</head>
But it seems to be wrong?
|
|
|
|
|
Member 4704143 wrote: But it seems to be wrong?
What seems to be wrong ? Any error ? I have already told you please check the syntax.
Member 4704143 wrote: var TextID="<%TextBox1.ClientID")";
var TextID="<%TextBox1.ClientID%>";
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hey.. he made script runat=server
That means it will not defined as Javascript.
|
|
|
|
|
Abhishek Sur wrote: Hey.. he made script runat=server
That means it will not defined as Javascript.
I haven't Noticed that !
Thanks Abhishek !!
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Abhijit Jana wrote: Thanks Abhishek !!
Cheers.
|
|
|
|
|
The only problem that I see in your code is runat="server" in the script block.
If you specify a script block as runat="server" it will take it as C# / VB.NET block based on the language.
So remove the runat = server and also use
OnClientClick to define javascript block.
use this :
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:checkValue2(this)" />
<script type="text/javascript" >
function checkValue2( obj)
{
if (obj.value == "")
alert ("empty");
else
alert ("not empty");
}
</script>
this will work.
|
|
|
|
|
Yep ... It worked! Thank kiu so much!
|
|
|
|
|
Good Catch.
|
|
|
|
|
Hi,
I need to Freeze the Header of a GridView.
I used the following property in Style of Header:
position:relative;
top:expression(this.offsetParent.scrollTop);
This works in IE8 compatibility view. but not in Chrome, Firefox or IE8.
can anyone please help me in this.
Thanks
|
|
|
|
|
|
Hi Abhijeet,
I also did the same to freeze the header. But its not working in IE8, Mozilla and Chrome.
I could not run your code.
Getting error: "Could not load file or assembly 'System.Web.Extensions,..."
Any suggession?
|
|
|
|
|
Anurag Gandhi wrote: I could not run your code.
Getting error: "Could not load file or assembly 'System.Web.Extensions,..."
Just fix this error using :
http://forums.asp.net/t/1135367.aspx[^]
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
do not use expression in CSS...
Browser renders it for every action, thus the site will be slower. Even mouse-move will call it also.
|
|
|
|
|
Abhishek Sur wrote: do not use expression in CSS
I agree with you. But sometimes you have no other option.
|
|
|
|
|
If Any One Is Familiar With Grey Box
Plz. Answer This.
" How To Open GreyBox In Another Grey Box"
|
|
|
|
|
hi all,
we want to find if the text in thetextbox is selected or not .
its working in Internet expolorer.
IE code
if(document.selection.type == 'Text')
{
return true;
}
but it is not working in FireFox .
Can any body tell how to do it in FF.
Thanks in advance.
|
|
|
|
|
do you check for document.selection.createRange for IE ?
Use like this :
var txt = '';
if (window.getSelection)
txt = window.getSelection();
else if (document.getSelection)
txt = document.getSelection();
else if (document.selection)
txt = document.selection.createRange().text;
I think this will do the trick.
|
|
|
|
|
hi ,
i used it , its not working .
i.e it is triggered if the cursor is just the textbox .
actually we want to enable the input only if the text is selected . i.e it is one condition.
and even return true; is not working in FF.
so is there any other way we could do it .
|
|
|
|
|
You need to focus before you call selection.
Use this function :
function ShowSelection()
{
var textComponent = document.getElementById('Editor');
var selectedText;
if (document.selection)
{
textComponent.focus();
var sel = document.selection.createRange();
selectedText = sel.text;
}
else if (textComponent.selectionStart)
{
var startPos = textComponent.selectionStart;
var endPos = textComponent.selectionEnd;
selectedText = textComponent.value.substring(startPos, endPos)
}
alert("You selected: " + selectedText);
}
I think this will solve the problem.
|
|
|
|
|
Hi ,
sorry for late reply.
but i got the solution to find if the text is selected in a textbox.
@abhishekh the by u was helpful to for the solution.
it is something like,
i.e
var s1= srcElement.selectionStart;
var s2= srcElement.selectionEnd;
if( document.selection )
{
if(document.selection.type == 'Text')
{
statements .....
}
else
{
if ( s1 != s2)
{
statements....
}
}
which is very simple.
Thanks and Regards,
sriharsha
|
|
|
|
|
Hi Guys,
I know that this is an ASP.Net forum, but just in case some of you still remember about the classic ASP, I have one question.
How can I assigned connection in Classic ASP using the MSSQLServer 2005?
I tried this code below, but I got an error.
Below is the connection string I have tried, but has an error
Application("ConnStr") = "server=PC\SQLEXPRESS;database=TestDB;Trusted_Connection=True;"
What's wrong with it?
hifiger2004
|
|
|
|
|
|
I guess ASP uses class ADO for data base connection .You need t provide provider information
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
|
|
|
|
|
hifiger2004 wrote: What's wrong with it?
Everything
Google for ado, check connectionstrings.com for connection details
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|