Logout button intercept enter key - html

I have asp.net page like this: There is a form that contains all, inside it a LoginStatusand some other controls like TextBox and ImageButton.
My problem is that: when we press Enter in the Text box, the LogOut button is pressed, then the user goes out. There is a way to avoid it?
I tried with javascript, but my controls are inside ajax panel and it is very complex, there is a html way?
Regards,
Antonino

Wrap the TextBox or the HTML containing the TextBox with something like this:
<div onKeyDown="return (event.keyCode!=13);"> ... </div>
If you do want something to happen when the enter key is pressed other than the LogOut button you can wrap the content inside a Panel and assign a DefaultButton like this:
<asp:Panel ID="Panel1" runat="server" DefaultButton="Button2">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="LogOut" />
<asp:Button ID="Button2" runat="server" Text="Cancel" />
</asp:Panel>
Now when the enter key is pressed in either TextBox the Cancel button will fire.

Related

What causes the edit method activation in a gridview aspnet

I have an asp:button tag
<asp:Button runat="server" Text="Edit" CommandName="Edit" />
whenever i press it im redirected into the onrowediting event
this is my gridview:
CssClass="fl-table" AllowPaging="true" AllowSorting="true" PageSize="15" RowStyle-CssClass="GvGrid"
OnSelectedIndexChanged="OnSelectedIndexChanged"
OnSorting="gridView_Sorting"
OnPageIndexChanging="GridView_PageIndexChanging"
OnRowEditing="grdIdkun_RowEditing"
OnRowUpdating="grdIdkun_RowUpdating"
OnRowCancelingEdit="grdIdkun_RowCancelingEdit">
<PagerStyle CssClass="cssPager" />
I was wondering how my button knows its time to activate edit method when I press EDIT?
** is the attribute 'commandname' tells it directly, now ure on edit ? so its firing the onrowediting event?
I was also wondering if I could have the functionality of that line:
<asp:Button runat="server" Text="Choose" CommandName="Select"
under the input tag? such as :
<input type="button" runat="server" value="Select" """"(somecommandactivation)="Select"/>
thanks!

<a href> tag in TextBox in GridView

This is not a pretty application by any stretch. It's only meant for a select few to use in the office and does not require street appeal. With that said...
I have a gridview with the following template column:
<asp:TemplateField HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblAction" runat="server" Text='<%#(Eval("Action"))%>'
ToolTip="Action to be Taken"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtAction" runat="server"
TextMode="MultiLine" Width="450px" Height="100px" ValidationGroup="UpdateFU"
Text='<%#Eval("Action")%>'
CssClass="RequiredText" ToolTip="Follow-Up Action">
</asp:TextBox>
<asp:RequiredFieldValidator ID="rfv_txtAction" runat="server"
ControlToValidate="txtAction" ErrorMessage="FollowUp Action is Required"
Text="*" ValidationGroup="UpdateFU">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtAction" runat="server"
TextMode="MultiLine" Width="250px"
ValidationGroup="UpdateFU"
CssClass="RequiredText"
ToolTip="Follow-Up Action">
</asp:TextBox>
<asp:RequiredFieldValidator ID="rfv_txtAction" runat="server"
ControlToValidate="txtAction" ErrorMessage="FollowUp Action is Required"
Text="*" ValidationGroup="AddFU">
</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
For the example that is causing me trouble, the data in the field that is bound to this column is: **Testing with a link. Google**
The label in the ItemTemplate displays as I expect it to. The regular text is not hyperlinked and the hyperlink text is. Please see the included image:
ItemTemplate
When my row is in Edit mode, it also displays in the TextBox as I would suspect. Please see the included image: EditItemTemplate
When I attempt to Save or Cancel the record, the gridview does not recognize that the command button was clicked. It just sits there. If I remove the text that references the tag (leaving from my example, **Testing with a link.**), it works beautifully. The only problem being that I can't save any text in the textbox with my link.
Any help is greatly appreciated.
I think you are using UpdatePanel around your GridView. That is why you are missing exceptions if you are not checking the browser console. And that exception could very well be A potentially dangerous Request.Form value was detected from the client
Fixes for that here
A potentially dangerous Request.Form value was detected from the client
A potentially dangerous Request.Form value was detected from the client
https://www.codeproject.com/Tips/297679/A-potentially-dangerous-Request-Form-value-was-det
https://www.aspsnippets.com/Articles/ASPNet-Error-A-potentially-dangerous-RequestForm-value-was-detected-from-the-client.aspx

asp Textbox & HTML Input - Values always empty

I have an asp Textbox for a username and a HTML input for a password, these are both server controls and are contained in the master page (in a modal popup).
<input runat="server" Class="login-input" id="txtPassword" placeholder="Password" type="password"
<asp:Textbox style="float:left; margin-right:25px;" runat="server" id="txtUsername" Class="login-input" Placeholder="Username" name="txtUserName"/>
I also have a login button hooked up to a handler in the code behind. However the value of the 2 input boxes is always empty.
I had to include UseSubmitBehavior="False" on my button as this was the only way i could get my click event to
<asp:Button UseSubmitBehavior="False" runat="server" Class="login-button" ID="btnLogin" Text="Login" />
Not sure what's going on here, i have checked my code and definitely only have 1 form tag, which i heard can cause this.
It turned out that at runtime my modal was not contained within the tags.
Therefore i had to use
$('#divname').parent().appendTo($("form:first"));
within my script to move the elements back within the form tags.
(There were 2 modal elements outside) I found this out by using f12 dev tools/firebug.

Using Special HTML symbols inside ASP Button Controller

I would like to display an arrow inside an ASP Button Controller.
The arrow will display perfectly if I used an HTML button.
<button>&#x25B2</button>
I know it works because I can insert HTML tags inside <button>. But the same will not work with an ASP Button.
<asp:Button ID="Button1" runat="server" Text="&#x25B2" />
Is there any way to display an arrow inside the ASP button?
I'm pretty sure you just need a delimiter (;) at the end of the special character:
<asp:Button ID="Button1" runat="server" Text="▲" />
or try
<asp:Button ID="Button1" runat="server">▲</asp:Button>

Ajax:ModalPopup js exception, BackgroundCssClass is null

I use a modal popup extender, i followed all the instructions on the toolkit sample page, except that i didn't set the property BackgroundCssClass.
this is what happens:
Is there a way I can get rude of it without setting the cssclass prop?
I don't need any styles.
If the answer is NO then please show me an example how to set it with a cssclass (even dummy).
Thanks in advance.
Here is the code:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<div style="size: 100%; vertical-align: middle">
<asp:LinkButton ID="lnkUpload" Text="Upload" ToolTip="Upload new file" runat="server" OnClick="lnkUpload_Click" />
<cc1:ModalPopupExtender ID="lnkUpload_ModalPopupExtender" runat="server" Drag="true" PopupDragHandleControlID="pnlUploadTitle" DynamicServicePath="" PopupControlID="pnlUpload" Enabled="True" TargetControlID="lnkUpload" CancelControlID="btnCancel" />
</div>
<asp:Panel ID="pnlUploadTitle" runat="server" Visible="false">
<center>
Upload file
</center>
</asp:Panel>
<asp:Panel ID="pnlUpload" runat="server" Visible="false">
<center>
<br />
<asp:FileUpload ID="upFiles" runat="server" /><br />
<br />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<br />
</center>
</asp:Panel>
</div>
</form>
You can set the ModalPopupExtender's backgroundCssClass within the actual HTML markup.
Example from the asp.net modal popup page:
<ajaxToolkit:ModalPopupExtender ID="MPE" runat="server"
TargetControlID="LinkButton1"
PopupControlID="Panel1"
**BackgroundCssClass="modalBackground"**
DropShadow="true"
OkControlID="OkButton"
OnOkScript="onOk()"
CancelControlID="CancelButton"
PopupDragHandleControlID="Panel3" />
I spent ages looking up a solution for the similar problem
Set your PopUpControlId to be the ClientID of the control.
It solved the problem for me.
Also read more on: Codeplex
Ha-ha, I remember more then 2 years ago in AJAX beta not setting the BackgroundCssClass property caused modal popup not to be really modal, but just popup. I remember setting a style class solved the problem. I haven't used AJAX for a long time, it's funny if similar problems still persist.
Anyway, create stylesheet class inside your ASPX page or in CSS file referenced form it and set the property value to it. Maybe, this will also help.