Add tooltip programmatically on asp.net web page [duplicate] - c#

This question already has answers here:
Tooltips for Button elements
(8 answers)
Closed 7 years ago.
I have this code on my project.
string="my string"
how i show this string on a button as a tool-tip. I want this to do programmatically. I want this to do in my code not the design.
i do my codings in asp.net with c# language

Here's how to add the tooltip programmatically
just get the id of the button
<asp:Button id="button1" Text="Submit" runat="server" />
in your code behind:
//do some code to retrieve data from database and store it to this variable
String tooltip = "some text";
button1.ToolTip = tooltip;

Related

Numeric updown TextBox not displaying buttons in IE [duplicate]

This question already has answers here:
<input type="number"> not working in IE10
(6 answers)
Closed 4 years ago.
I have an HTML input control
<input id="textBox1" class="form-control" runat="server"/>
I add the following C# code to make it a Numeric updown control:
textBox1.Attributes["type"] = "number";
textBox1.Attributes["min"] = "0";
textBox1.Attributes["max"] = "50";
textBox1.Attributes["step"] = "1";
This is working fine in Chrome but in Internet Explorer the updown buttons are not displaying.
What should I do to display the buttons in IE also?
I know that a similar question has been asked here but I thought adding the Attributes in code behind could overcome this as suggested here in Sachin Gupta's answer.
See https://caniuse.com/#feat=input-number
Comment attached to IE versions is:
UI widget does not include increment/decrement buttons.

accessing an ASP HiddenField within a .JS file [duplicate]

This question already has answers here:
Get the Value of an asp:HiddenField using jQuery
(8 answers)
Closed 5 years ago.
I assign a value to an ASP hidden field within the page load but can't access that value in my JQuery. I added an alert as a test and it comes up 'undefined'. Am I making a syntactic error?
<asp:HiddenField runat="server" id="hfID"/>
hfID.Value = "Test";
alert($('#hfID').Val());
Asp.Net Webforms mangles the id you give it to make sure it's unique on the page. You can use class as a selector or modify your jQuery selector so that it's looking for an id that ends in hfID.
$("[id$='hfID']")

asp.net C# get textbox lenght from code behind [duplicate]

This question already has answers here:
Determine number of characters entered into textbox with C#
(4 answers)
Closed 8 years ago.
I would like to alert user about length of the mobile number which he has entered.
my textbox ID : txt1
my code behind :
if (txt1.txt.??? < 11)
{
alert;;;
}
please suggest me about tricks to perform this action.
thanks in advance.
To get the length of a textbox value from behind code.
if(txt1.Text.Length < 11)
{
//Your code here
}
else
{
//Your Code here
}
However, why don't you used a textbox masked extender like Ajax or a RegularExpressionValidator validation?
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Enter valid Phone number" ControlToValidate="txt1" ValidationExpression="\d{10}" ValidChars="()-" ></asp:RegularExpressionValidator>

ASP.NET C# target blank is not working on LinkButton [duplicate]

This question already has answers here:
link button property to open in new tab?
(8 answers)
Closed 3 years ago.
I have this linkbutton here...
<asp:LinkButton ID="linkButton" CssClass="Button" runat="server" target="_blank">Button Text</asp:LinkButton>
but the target blank does not work, it does not open the page in a new tab, it opens it in the same tab.
What Am I doing wrong?
There is an href, its gets assigned in the code behind like so
linkButton.PostBackUrl = "http://www.nfl.com";
but still the target blank does not work....
You can try this. Hope it helps:
<asp:LinkButton ID="linkButton" OnClientClick="window.document.forms[0].target='_blank';" runat="server">Button Text</asp:LinkButton>
linkButton.PostBackUrl = "http://www.nfl.com";
Below code works fine:
OnClientClick="window.document.forms[0].target='_blank';
In ASP.NET web forms a button, linkbutton, imagebutton or similar control actually just submits the underlying form. In order to open this in a new window you can modify the target property of the "form" using JavaScript. We also need to undo the modification after the click otherwise further button clicks will unintentionally target the new tab, which we can do using a setTimeout and blanking the target again.
<asp:LinkButton ID="uiNewTabExample" Text="PDF" OnClick="uiNewTabExample_Click" OnClientClick="window.document.forms[0].target = '_blank'; setTimeout(function () { window.document.forms[0].target = '' }, 0);"
runat="server" />

Does the <asp:Textbox> have a onFocusLost event? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Lost Focus method for asp.net textbox?
i want to check the data entered by user on the client side.
it is necessary for me to use control.
is there any way so that i can check after client move on to the next input and i can check the data by javascript ?
<asp:TextBox ClientIDMode="Static" onblur="return userCheck(this.id)" onkeyup="return userCheck(this.id)"
ID="txtUserName" runat="server" Width="180"></asp:TextBox>
here i have used two events but i want to use only one.
You can do that with onblur event using javascript.
f.e something like that:
<asp:TextBox runat="server" onblur="Javascript:alert('1234');" />
For what you want to do, you can set the textbox to have AutoPostBack=True; any time the text in the box is changed and the box loses focus, it will post back to the page; you can use the TextChanged property, as well, if you don't want to post back, which will check to see if the text of the TextBox has been changed between posts.
Finally, you can bind the JavaScript onFocus and onBlur events to the textbox, and handle changes to its contents via JavaScript:
http://support.microsoft.com/default.asp…
Source: http://answers.yahoo.com/question/index?qid=1006040618831

Categories

Resources