|
I have a gridview that row's cells contain textboxes. Currently, I highlite the row, in yellow using javascript, by changing the backgroundColor of each of the rows cell's textboxes. To set the backgroundColor I use the .childNode[0].style.backgroundColor = 'Yellow', see code below:
gridViewCtl.rows[index].cells[i].childNodes[0].style.backgroundColor = 'Yellow';
Now, I have a set of css files defined and would like to use a color defined in my css. Does anyone know how this can be done?
Thanks,
Steve
|
|
|
|
|
CSS:
.whatever { background-color: #ffff00; }
...
JS:
gridViewCtl.rows[index].cells[i].childNodes[0].className = 'whatever';
|
|
|
|
|
I am using .className and setting my CSS value; however, the value is not being picked up. I ran into a similar problem because I had a default .skin for textboxes. In this case I'm not sure why it is not picking up my CSS tag value.
Thanks,
Steve
modified on Tuesday, October 21, 2008 3:33 PM
|
|
|
|
|
The problem was that I was setting the controls backgroundColor using .style.backgroundColor = 'White' before I was setting the .className using css. When I used .className with both 'NormalWhiteBackColor' and 'YellowBackColor' css, things worked fine.
|
|
|
|
|
Hello
I am using this.ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script language="javascript">alert('" + ex.Message.Replace("'", "") + "');</script>"); to show errors on an aspx webpage which are caught using a try catch block.
When the error message contains "\r\n" it throws an Unterminated String Constant error in javascript.
I can resolve this quite easily using this.ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script language="javascript">alert('" + ex.Message.Replace("'", "").Replace("\r\n", @"\n") + "');</script>");
Does anyone know a more elegant solution to this though, as i presume "\n" etc. also might cause the same problem?
Thanks
|
|
|
|
|
|
Sorry I think you misunderstood me... for e.g. error message "Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index" renders as:
alert('Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index');
It should render as:
alert('Index was out of range. Must be non-negative and less than the size of the collection.\nParameter name: index');
so as not to throw a javascript error.
I suppose I could use this.ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script languaue="javascript">alert('" + ex.Message.Replace("'", "").Replace("\r", "").Replace("\n", @"\n") + "');</script>");
Just thought there might be an easier solution...
Thanks
|
|
|
|
|
Use "\\n" . That makes the first two slashes the escape sequence, and the n a plain character.
|
|
|
|
|
To properly escape a string value that you put in a javascript string literal, you replace \ with \\ and ' with \'. Before that you can replace a line break with the escape code \n.
And don't use the language attribute in the script tag. It's been deprecated for many years.
this.ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script type="text/javascript">alert('" + ex.Message.Replace("\r\n", @"\n").Replace(@"\", @"\\").Replace("'", @"\'") + "');</script>");
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
How to write client-side validation code?
E.G.
a page has a dorpdownlist(identityDdl), a TextBox(identityTxt) and a TextBox(remarkTxt)
identityDdl has 3 items: Indentity Card, Martial Certificate and other
when selected "Indentity Card" or "Martial Certificate " check id of the correct format use CustomValidator on client, when selected "other" dont check.
if the characters more than 300 of remarkTxt.
With CustomValidator How to validat on client?
How to verify the results back to the CustomValidator?
Thanks.
|
|
|
|
|
You can use javascript for it.get the control by its ID,then check the value and for correct format you can REGEX.
Cheers!!
Brij
|
|
|
|
|
I saw so many people write like this:
<script type="text/javascript">
function valComments_ClientValidate(source, args)
{
if (args.Value.length > 10)
args.IsValid = false;
else
args.IsValid = true;
}
</script>
But I try it not successful.
How to setting the page validat is true or false?
|
|
|
|
|
This looks OK. Do you have firebug installed? If yes, try to debug your JS.
|
|
|
|
|
Hi:
I am usig Calender extender control to select date.it works fine but the issue is while storing in SQL table the date is stored with Defaulttime like below:
"10/7/2008 12:00:00 AM".My Requirement is like if a customer calling yesterday 10.30AM .Today I am entering the Customer calldetails date " 20-10-08 " with time 10:30AM it has to be stored like 20-10-08 :10.30AM.I want to know the following details
1)Is there any control to select Date and Time simultaneously.
2)How to Enter the Date and Time in Storedprocedure.(Here the Time meant not default time but user defined time like 10:30AM.plz kindly let me know its very urgent.
Thanks
suresh
|
|
|
|
|
|
can anybody please guide me what are the key points to keep in mind while converting a desktop/client server application to a web appliation
and
next question of mine is in previous application developer has used more than 20 datatables to in which on the beggening he is filling the data from the different tables and then using them in the forms...
now what will be the alternative or best approach to do same functionality in the web so that each datatable is accessable in all froms....?????
1) do i have to fill all the datatables and keep them into sesssion if i do that will these session effect the website while loading time???
umerumerumer
|
|
|
|
|
Main thing to remember, desktop is stateful, web is stateless. And yes, holding 20 datatables in session will be bad for performance.
If really necessary (and if they are application general stuff), consider the cache.
|
|
|
|
|
mr_muskurahat wrote: can anybody please guide me what are the key points to keep in mind while converting a desktop/client server application to a web appliation
1. Web Application should be deployed in a central location (Web Server ) , so you need to maintain session for all user becase all user access the same application.
2. Look into server side and client side code. avaoid unnecessary post back to server.
mr_muskurahat wrote: 1) do i have to fill all the datatables and keep them into sesssion if i do that will these session effect the website while loading time???
Yes you can store your datatable in a session and can access from all of the appliction.
at the time of Storing Datatable in a session , you should consider about the datatable size and also session size etc., because it can damage your application performance.
If DataTable Data is same for all user and not frequently changed then you can Use Caching or Application Variable.
cheers,
Abhijit
|
|
|
|
|
For your first question
A: You need to keep in mind all the user based data,so need better session management(try to reduce session data per user).
B: Minimise the size of aspx pages becuse it can severely harm the perfomrmance of your application.
C: If you application is very secured,don't send the valuable data in plain text always encrypt it and use HTTPs.
And for second,
if they are shared for all users the use cache else it will be better to use some database smartly else you apllication is going to be very slow.
Hope your query will be resolved by this
Cheers!!
Brij
|
|
|
|
|
Hi,
I need to show message box(alert) with out use of javascript.
How should i get this?
Thanks in advance.
Regards,
Venkat
|
|
|
|
|
Use AJAX model Extender control then, which is heavy and time consuming
What is the problem in using javascript ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
AJAX Also uses javascript (aJAx)
You can embed a VBScript and display a messsagebox (MsgBox), however i'm not sure if all platforms support this messagebox.
|
|
|
|
|
I dont want any scriptting languages.Using only c#
|
|
|
|
|
Some browsers cannot support javascript.So only i need with out javascript.
|
|
|
|
|
You can't. Simple enough. Unless you just want it to open on the server...
You want dynamic things to happen on the client, must use script.
|
|
|
|