bootstrap modal popup button does not have onclick serverside event - asp.net

my web page has a view result button which is a toggle for bootstrap modal popup.
I am unable to create a onclick event for it as control does not go to server side when I click it, only a popup is displayed. How can I get the onclick event to raise serverside event handler.
As you can see I tried creating OnClick event handler but with no success.
<p class="text-center"><button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal" id="btnshowmodal" onclick="Save_Result" runat="server">View Result</button>

change the 'button' to 'asp:Button` because this is an asp.net control that triggers events on code behind.
<asp:Button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal" id="btnshowmodal" onclick="Save_Result" runat="server" Text="View Result"></asp:Button>
left the other attributes as they are - just set the Text. Will be render not a button but an input, but your job will be done.

Related

Open bootstrap modal from codebehind crashes tooltips

I build asp webform page (vb.net)
My tooltips crashes when I open modal from code behind using below code
Dim sb As New System.Text.StringBuilder()
sb.Append('&ltscript type='text/javascript'&gt')
sb.Append('$('#SetTime').modal('show');')
sb.Append('&lt/script&gt')
ScriptManager.RegisterClientScriptBlock(Me, Me.[GetType](), 'SetTimeModalScript', sb.ToString(), False)
If I open the same modal form using button eg.
&ltbutton type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#SetTime"&gt Launch demo modal
&lt/buton&gt
everything works fine.
To initialize tooltips I use
$(document).ready(function () {
$('[data-tooltip="true"]').tooltip();
});
I try to find solution but I gave up after few hours.
I must use this code to open modal because I open it to display data for specific gridview row.
Edit
Here is part of code where I put data tooltip :
<asp:LinkButton runat="server" CssClass="btn btn-primary btn-xs" CommandArgument='<%#Eval("ID") %>' CommandName="SetTime" data-tooltip="true" title="Ustaw czas rozpoczęcia i zakończenia zlecenia" data-container="body"> <i class="fa fa-clock-o"></i> </asp:LinkButton>
I tried also with data-target="tooltip" instead data-tooltip="true"

Boostrap datetimepicker not triggering asp textbox's onTextChanged event

I can't seem to get my textbox to automatically postback after selecting a date from the bootstrap datetimepicker (Downloaded from here). I stil have to press enter for the event to trigger.
<div class="span3">Date<br />
<div id="datepicker" class="input-append date">
<asp:TextBox ID="txtDate" runat="server" OnTextChanged="txtDate_TextChanged" AutoPostBack="true" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
When you select a datetime the input control not lose focus, so the postback not occur. You can force a postback in the event triggered from the datepicker like (not tested):
el.on('changeDate', function(e) {
__doPostBack('<%= txtDate.ClientId %>','');
});
where el is the element on you bind the datetime picker.
Alternatively you can force a blur like:
el.on('changeDate', function(e) {
$('<%= txtDate.ClientId %>').blur();
});
Ref: http://tarruda.github.io/bootstrap-datetimepicker/

tinymce button trigger click not working

I'm using wordpress and i add some button on editor
i wants to trigger click on that well its triggering click
but not opening light box
for example that button codes looks like
<td style="position: relative">
<a title="Add New Alert" aria-labelledby="content_admin_alert_voice" onClick="return false;" onMouseDown="return false;" class="mceButton mceButtonEnabled mce_admin_alert" href="javascript:;" id="content_admin_alert" role="button" tabindex="-1">
<img alt="Add New Alert" src="http://www.xyz.com/themes/abc/wp-content/themes/abc/admin/js/../img/icon-alert.png" class="mceIcon"><span id="content_admin_alert_voice" style="display: none;" class="mceVoiceLabel mceIconOnly">
Add New Alert
</span>
</a>
</td>
and i'm clicking on #content_admin_alert but actions not happens like we actually click on that button
I haven't played with TinyMCE in a while, but the onClick and onMouseDown events are returning false, which would essentially cancel any click actions.

asp net jquery popup dialog form in asp:formview

i have following problem, i am using a popup jquery dialog with asp:formview .
the purpose of this popup is for user to enter a hyperlink which is placed then in textbox control in formview
the popup dialog div is located outside a formview just after body tag
<body style="background-color: #FFFFFF; font-family:Lucida Console;">
<div id="dialog-form" title="sdfdfsdf" style="font-size:14px; ">
<form>
<fieldset>
<label for="link">sdfdf</label>
<input type="text" name="sdfsdf" id="link" size="32" />
</fieldset>
</form>
</div>
<form id="form1" runat="server" style="margin-top:50px;" >
<div>
<asp:FormView ID="FormView1"
.......
<InsertItemTemplate>
...
<sometextbox ...../>
<button id="create-user" class="ui-state-default ui-corner-all">Create link</button>
...
</InsertItemTemplate>
After clicking a button a popup window is shown BUT the page starts to refresh immediately
and of course the popup is then hidden.
If I relocate the button outside the formview - the page is not refreshed, but i need it in formview..
Any idea what to do?
add the following attribute to the button:
onclick="javascript: return false;"
this behavior should not come out because it is a button not submit button.
it seems when it is inside the form view a submit action is attached to it, check your jQuery scripts maybe you mistakenly added onclick submit while attaching the dialog.
I found my answer:
clientId must be used:
FTB_API['<%=FormView1.FindControl("AdminCommentTextBox").ClientID%>'].SetHtml(...)

JS callback on asp button

Um, I have this guy:
<div class="buttonRight"><asp:Button ID="btnOK" runat="server" Text="OK" Width="68px"/></div>
which renders out to
<div class="buttonRight">
<input type="submit" name="_$_$pc$pc$tabTO$_$uc0$popupSelectCompetition$btnOK" value="OK" id="____pc_pc_tabTO___uc0_popupSelectCompetition_btnOK" style="width:68px;" /></div>
I need to call some javascript on that button without altering its behavior otherwise. I tried putting an OnClick asp attribute but that seems to be for postbacks to call server code, not passing through a javascript hook to the rendered html.
I also don't understand how the input being type='submit' affects me.
Add your client-side code to the OnClientClick property :
<div class="buttonRight">
<asp:Button ID="btnOK" runat="server" Text="OK" Width="68px"
OnClientClick="alert('client side scripts here');"/>
</div>
OnClick property used for server side events.
Or add onclick attribute to your control like that at code behind :
btnOK.Attributes.Add("onclick", "alert('client side scripts here');");

Resources