I have a textbox with a spinner that allows the user to select numbers. But if a certain user is logged in then I want to disable the textbox and the spinner.
<asp:TextBox runat="server" ID="txtCreditDays" CssClass="integeronly spinner" Text="0" Width="20px"></asp:TextBox>
I used this to disable the textbox:
txtCreditDays.Enabled = false;
But the user can still click on the spinner and change the value. I need to disable the spinner to but since it is a CssClass I don't know how.
Here is the code for the spinner:
.spinner {
border: 0px solid #85B1DE !important;
font-weight:normal !important;
padding:0px !important;
background: none !important;
min-width: 60px !important;
}
I can't edit the CSS code because it is being used by other parts of the code.
You can use Replace method very simple.
txtCreditDays.CssClass= txtCreditDays.CssClass.Replace("spinner","");
I Don't know asp.net. But i can give you a logic through php.
In PHP, We do like this.
<input type="text" class="<?php if($user_loged_in){ echo "some_other_class"; } else { echo "spiner";} ?>">
Using an if statement could solve this in asp
Related
I have a gridview with a checkbox in every row. When put into Edit mode the Checkbox can be checked/unchecked; but I don't want the checkbox to be editable in any other mode. The user easily might get confused by checked boxes that do not reflect the real values saved back in the database.
<asp:CheckBox id="checkboxCustomerRequired" runat="server" Checked='<%# Bind("CustomerRequired") %>' Enabled="false" CssClass="Check"/>
Possible workarounds I tried:
1) Setting enabled = false
This achieves the goal, but the greyed out box is ugly and prevents from capturing it's state in one glance. Therefore I tried to set the forecolor of the box in the OnRowDataBound Event back to white, but it doesn't work. Checkbox.ForeColor = System.Drawing.Color.White;2) Using OnCheckedChange EventThe idea is to set it's state back once it had been changed. The problem is that I'm moving within a gridview and I can't figure out how to establish the row in which the Checkbox Click had occurred. This doesn't seem to be possible in the given situation.Any suggestions?
Martin
You can make the CheckBox read-only by returning false in the onclick client-side event:
<asp:CheckBox ID="checkboxCustomerRequired" runat="server" onclick="return false;" ... />
Have you tried syling the disabled state with CSS, so it's disabled but still looks the way you want it to?
input[type=checkbox][disabled]{
outline:1px solid red; // or whatever
}
The checkbox appearance of a disabled is being controlled by the browser. It is not advisable to tamper with this since it will look different in each browser; An appearance users are probably already familiar with. See the comparison below for how each browser and OS will display a disabled checkbox.
If you really want to unify the style of the checkbox, you can create a stylesheet that overrides the various attributes (background, border, etc.) and apply them to the :disabled state.
input[type=checkbox]:disabled {
-webkit-appearance: none; /* disable chrome and safari styles */
width: 12px;
height: 12px;
background: white;
border: solid 1px black;
vertical-align: middle;
}
<input type="checkbox" disabled>
<label>This is a checkbox</label>
Is there a way to add a button click event to a button I create myself?
I am using Visual Studio Premium 2013. I was trying to customise the appearance of the standard button control from the toolbox but it wasnt doing what I wanted (there were issues with border-radius and other things). So I decided to make my own button. Its a div, styled with this css and wrapped with an anchor tag:
<div id="loginBtn">Login</div>
#loginBtn {
width: 60px;
height: 30px;
margin-left: auto;
margin-right: auto;
background: #3B647F;
border: 1px solid black;
box-shadow: 3px 3px 5px gray;
border-radius: 5px;
text-align: center;
line-height: 1.75;
}
But how do I add a click event to this button? I tried instead using a hyperlink control like this:
<asp:HyperLink ID="hyp1" runat="server"><div id="loginBtn">Login</div></asp:HyperLink>
But I couldnt find a way to add a click event to a hyperlink.
Anyone have any ideas?
Use asp:LinkButton, you can add OnClickEvent. You can read how to do it in this MSDN Article
ASPX:
<asp:LinkButton id="LinkButton1"
Text="Click Me"
OnClick="LinkButton_Click"
runat="server"/>
Code behind:
void LinkButton_Click(Object sender, EventArgs e)
{
Label1.Text="You clicked the link button";
}
I'm using Ajax control toolkit's combobox in my website. I'm binding custom type data to it dynamically. Here is the aspx code I put for it.
<ajaxToolkit:ComboBox ID="ddlAddAccount" runat="server" AutoPostBack="False" DropDownStyle="DropDownList" AutoCompleteMode="SuggestAppend" CaseSensitive="False" CssClass="ComboBoxStyle" ItemInsertLocation="Append"/>
Here is the CSS to that:
.ComboBoxStyle .ajax__combobox_itemlist
{
border: 1px solid YellowGreen;
font-size:medium;
font-family:Courier New;
padding-left: 0px;
list-style:none;
list-style-type:none;
}
The problem I'm facing is that when the DDL is rendered on the page, it is showing some weird boxes inside the dropdown. They seem to be bullets. But despite putting list-style-type : none; in the css, there is no change in the output. That is, the weird boxes still show up. Here is the screen clip of the rendered combo box:
I even checked the rendered HTML mark up to see if there is any character that is being appended but there isn't. The <li> tags in the <ul> tag simply has the list of elements that are binded.
Any Idea what this can be and how to get rid of these?? I tried ddlAddAccount.Items.Clear(); before binding but that didn't help.
Thanks a lot!
If it is indeed list bullet items you can try putting !important in the style to make sure that there is no list style applied.
.ComboBoxStyle .ajax__combobox_itemlist
{
border: 1px solid YellowGreen;
font-size: medium;
font-family: Courier New;
padding-left: 0px;
list-style-type: none !important; /* Add the important here */
}
I can't reproduce your issue but you must have some sort of css style being applied to ul or li tags that is causing this. I know you mentioned you unchecked all the styling on the control in the browser but there must be something you missed.
Hopefully this works.
Most probably some additional styling is conflicting with your combo-box.
Use a browser developer tool (F12 developer tools in IE, Tools --> developer tools in chrome) and isolate the CSS applied on your list.
Also the combo-box will not be rendered as <option>. It should be rendered as an unordered list (<ul><li>...</li>)
Does anyone have a better styled DropDownList or ready css file for the asp:DropDownList?
I could not find something finished at www?!
<asp:DropDownList ID="DropDownList1" runat="server" Width="50px">
</asp:DropDownList>
I could imagine something like jQuery UI style.
Thanks for your constructive answers!
I have used this in my project look's good.
Try this : link
.dropdown1 {
background: url(http://maxgxl.com/max4u/images/selectArrowDown.png) no-repeat 95% center;
width:150px;
border: 1px solid #000;
overflow: hidden;
border-radius:5px;
}
.dropdown1 select {
border:0px;
width:168px;
background:none;
}
The link you have shared here seems to be a comboBox. If you want to design your dropdownlist control then you can have your own styles as well.
Think of the same link that you have given here. It contains a textbox having a button whose background image is a small triangle that seems to be a dropdownlist, and a simple div/list control(ul-li) that contains all the items that are populated below the dropdown list.
Now you need to decide what you need to have in your design. based upon your requirement you can customize your dropdownlist here.
See this is just a way how you can create your customized dropdownlist of your own style. If you go for the jquery dropdownlist then you can have the same look and feel that you can have designed of your own. So you decide the things you want to have with your dropdownlist.
Thanks
.search_categories .select{
background: transparent;
line-height: 1;
border: 0;
padding: 0;
border-radius: 0;
width: 120%;
position: relative;
z-index: 10;
font-size: 1em;
}
I need to validate two separate group one by click button1,and another one is click button2
Two buttons are in separate user controls implemented in same page ,the validation to the first user control also validates the second one,i give the validation group for both user controls separately it don't work.
please help me...
the below code contains two user controls,that having the one button is in < uc1:UCEditRegisterUser> and anothe one is in < uc1:UCEditDoctorProfile>
<div style="width: 950px; margin: 0px auto 0px auto;">
<div style="width: 425px; min-height: 800px; overflow: hidden; float: left; padding-left: 17px;
margin-top: 30px;">
<uc1:UCEditRegisterUser ID="UCEditRegisterUser1" runat="server" />
</div>
<div style="width: 485px; min-height: 800px; overflow: hidden; float: right; margin-top: 30px;
padding-right: 20px;">
<uc1:UCEditDoctorProfile ID="UCEditDoctorProfile1" runat="server" />
</div>
</div>
This seems obvious so apologies
Make sure that the validation group on the validators within both user groups is exactly the same
Make sure that the button (or whatever) the triggers the validation also has the same validation group
make sure that the triggering button doesn't have the CausesValidation attribute set to false
You could consider making the ValidationGroup a property that is set externally on both controls. Might make things clear to you all all who inherit your code
I got the solution,
it needs to call the validation from the page event Page_ClientValidate("pwd");
the pwd in bracket is the validation group.
<script type="text/javascript">
function ValidateUserContrlos()
{
var isValid=false;
isValid=Page_ClientValidate("pwd");
if(isValid)
{
return true;
}
else
return false;
}
</script>
call the function from the button click like this
<asp:Button ID="btnSave" runat="server" Text="Save" onClick="btnSave_Click"
OnClientClick="return ValidateUserContrlos()"/>.
it solved thank u all for the support..