Jquery Model Window + DataGridview TemplateField - asp.net

I have a gridview on my Page. I want to open a jquery dialog on the click of the linkButton placed inside the itemtemplate of the gridview. I`ve added the js and css files on my master.aspx page. But still it doesnt open.
My Jquery CODE:
$('#gvLCStatus ContentPlaceHolder1_gvLCStatus_lnkbtnShipment_0').dialog({
create: function (event, ui) { }
('ContentPlaceHolder1_gvLCStatus_lnkbtnShipment_0').bind("dialogcreate", function (event, ui) {
});
});
MY Gridview ItemTemplate Field:
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkbtnShipment" runat="server">Shipment Status</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
I want to Open a Jquery Dialog on the click of this item template field.

Use OnClientClick like this.
<asp:LinkButton ID="lnkbtnShipment" runat="server" OnClientClick="return YourFunction(Parameter)')>Shipment Status</asp:LinkButton>

Related

Can one have client-side and server-side code invoked from an Asp:RadioButtonList?

I am currently invoking client-side functions and server-side functions from the same button click thus...
<asp:Button id="myButton"
runat="server"
cssclass="myButtonClass"
text="Do Stuff"
onclick="Do_Foo"
OnClientClick="Do_Bar();"/>
I was wondering if something analagous was possible for a radio button list...
<asp:RadioButtonList id="myRadioButtonList"
runat="server"
AutoPostBack="True"
onselectedindexchanged="Do_Fum"
...er...something here?>
<asp:ListItem ...or here perhaps?... Value="0">First Button</asp:ListItem>
.
.
You can use following approach: paste code below in page's Page_PreRender event handler
foreach (ListItem item in myRadioButtonList.Items)
{
item.Attributes["onclick"] = "if(!confirm('Are you sure?'))return false";
}
You can hook a change event to radio buttons in javascript like
$('#myRadioButtonList').change(function() {
alert('Handle Your Change');
});

how to set a default 'enter' on a certain button

There is a textbox on a ContentPage. When the user presses Enter in that textbox I am trying to fire a 'Submit' button on this ContentPage. I'd like to fire off that particular button's event.
Instead, there is a search textbox & button on the top of the page from a MasterPage, and this search button's event fires off.
How do I control to fire off this ContentPage's submit button, instead of the MasterPage's search button?
I am using Ektron CMS for my content management.
The easiest way is to put the fields and button inside of a Panel and set the default button to the button you want to be activated on enter.
<asp:Panel ID="p" runat="server" DefaultButton="myButton">
<%-- Text boxes here --%>
<asp:Button ID="myButton" runat="server" />
</asp:Panel>
if you need to do it from code, use
Me.Form.DefaultButton = Me.btn.UniqueID
Where btn is your button control.
You can use the DefaultButton property on either a server-side form control or Panel control. In your case, group the controls together in a Panel that should fire off the same button:
<asp:Panel ID="SearchBox" runat="server" DefaultButton="BtnSearch">
...
<asp:Button ID="BtnSearch" runat="server" Text="Search!" />
</asp:Panel>
....
<asp:Panel ID="UserPanel" runat="server" DefaultButton="BtnUserSubmit">
...
<asp:Button ID="BtnUserSubmit" runat="server" Text="Submit" />
</asp:Panel>
You can now use UseSubmitBehavior property to disable all the buttons you don't want to fire when hitting submit (check out the documentation for more info)
<asp:Button ID="BtnNotToFIre" runat="server" Text="Search" UseSubmitBehavior="false" />
Microsoft say:
<form id="Form1"
defaultbutton="SubmitButton"
defaultfocus="TextBox1"
runat="server">
enter link description here
$(document).ready(function(){
document.getElementById("text_box_id")
.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.keyCode === 13) {
document.getElementById("button_id").click();
}
});
});

how to fire click event for the textbox

how to fire click event for the textbox which is put under the gridview in item template in asp.net?
It is the same as making a clickevent outside a gridview. im using jqueryto do this
<asp:textbox id="textbox1" ontextchanged="textbox1_textchange">
<asp:linkbutton runat="server" id="hiddenbtn" onclick="textbox_click"/></asp:textbox>
<script>
$(document).ready(function() {
$("#textbox1").click(function () {
$('#hiddenbtn').trigger('click');
});
});
</script>

Calling browse file window of fileupload control

I have an ImageButton and a FileUpload controls in a child page of a master page. I would like to achieve something like when user click on the ImageButton, the browse file window will pop-up like what we did when we click on the Browse button of the FileUpload control.
How can call the browse file window of the FileUpload control when i click on the ImageButton?
have you tried this?
<script>
function browse() {
document.getElementById('<%= FileUpload1.ClientID %>').click();
}
</script>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="browse()"
ImageUrl="http://stackoverflow.com/favicon.ico" />

JQuery BlockUI with UpdatePanel Viewstate Issue

I have an update panel within a div that I modal using the JQuery plugin BlockUI. Inside the UpdatePanel is a textbox and a button. When I enter something in the textbox and click the button I am unable to retrieve the text in the textbox. When I debug it shows the textbox having no value.
<asp:UpdatePanel ID="upTest" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div id="divTest">
<asp:TextBox ID="txtTestVS" runat="server" /><br />
<asp:Button ID="cmdTest" Text="TEST" OnClick="cmdTest_Click" UseSubmitBehavior="false" runat="server" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
SERVER-SIDE:
protected void cmdTest_Click(object sender, EventArgs e)
{
string x = txtTestVS.Text;
}
This should clarify things. Here are the total contents of the page.
SHOW MODAL
<div id="divTest">
<asp:UpdatePanel ID="upTest" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtTestVS" runat="server" /><br />
<asp:Button ID="cmdTest" Text="TEST" OnClick="cmdTest_Click" UseSubmitBehavior="false" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
This is a common problem with dialog plug-ins. The problem is when content is put in the blockUI container, it's appended to the element, and no longer in the form being submitted to the server. To solve this you need to edit the blockUI code a bit:
Here's the source: http://github.com/malsup/blockui/blob/master/jquery.blockUI.js
Change this:
Line 262:
var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
to:
var layers = [lyr1,lyr2,lyr3], $par = full ? $('form') : $(el);
and this:
Line 382:
els = $('body').children().filter('.blockUI').add('body > .blockUI');
to:
els = $('form').children().filter('.blockUI').add('form > .blockUI');
That should get you going and the textbox values coming through.
(Response courtesy of Nick Craver https://stackoverflow.com/users/13249/nick-craver)
If you are trying to use blockUI on a button within an update panel (i.e. you click the button within the update panel and the UI gets blocked), you need to handle it using PageRequestManager events
prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(function() {
$.blockUI({ message: '<img src="../../Content/images/Busy2.gif" />' });
});
prm.add_endRequest(function() {
$.unblockUI();
});
Or on a button click, if you want to display a modal window with this text box and a button, you can try something like this

Resources