Forum Moderators: not2easy
HTH
You could use css to make a div look like an input field and that wouldn't be editable. So you can have an input field and your fake input div. Make the input display:inline and the div display:none when you want them to enter text. Then after they submit your form and the page is reloaded, make the input display:none and the div display:block or display:inline and you can use server-side code to read the post from your form and display it inside the div. So it will look like an input field but won't be editable, all using server-side code and css. You can even play with the css for your div to give it a grey background and different colored text.
Don't know if this helps, but it's an idea.
<added>Of course, you could just use server-side code to add "disabled" to your input field. I don't know why you would need to use css.</added>
In dotnet(ASP.NET), we can set the properties of the server side control at runtime(That is at the server side).
Depending upon the business logic, I need to make controls in my page Editable/Non-Editable - Visible/invisible - Mandatory(Changing background color of a control)
For doing this,
For Example, for a textbox server side control(which emits html textbox field to the clientside)
I need to write , three lines of code
textbox1.visible = true/false
textbox1.enabled = true/false
textbox1.cssclass = "Classname" - to made mandatory color change
Instead,
I want to write css classes with the above three combination
and just set the cssclass - one line instead of three lines.
Hope you now understood my requirement, thanks a lot for spending your time for. me
<script runat="server">
Dim isDisabled as String = ""
Sub Page_Load(...)
if [some circumstances..] then
isDisabled = " disabled"
end if
...
</script>
...
<input type="text" name="myVal1"<%= isDisabled %>>
<input type="text" name="myVal2"<%= isDisabled %>>
It's messy, but it works.
A more elegant solution might be to subclass the .NET Server Controls you're using and override their default value for disabled, depending on your business logic. So you'd create something like <krishire:TextBox id="myVal1"> from a class that inherits all the values of the TextBox control, but overrides the Enabled property if necessary (you should be able to do this by making that property static).
hth,
g.
Textbox1.cssclass = "Mandatory&visibility"
Textbox1.enabled = true