I have button, which should open a modal pop up with iFrame to a page.
Currently the button click opens a PostBackUrl,
I want a similar thing to happen here.
That is, I want to open the Iframe scr Page as postbackurl.
<asp:Button ID="btnCreateComp" runat="server" Text="Create Company" CssClass="button_style"
PostBackUrl="~/Company.aspx" />
<asp:Panel ID="Pnl1" runat="server" CssClass="PanelPopup">
<div>
<iframe id="iframe1" runat="server" height="500px" width="500px" src="" ></iframe>
<asp:Button ID="btnclose" runat="server" Text="Close" CausesValidation="false" />
</div>
</asp:Panel>
I think you should use jquery pop up because it is easier than modalpopupextender because I found it buggy some time there are a lot of pop up in jquery:
Jquery popup exmaples
I used this one and it is working perfectly (you can place what ever you want) for me:
Note:The best feature I like about Jquery it is not required that your control must have runat="server" it works with both HTML Controls and ASP.NET Controls.
Adding event handler to button:
<asp:Button ID="btnclose" runat="server" Text="Close" CausesValidation="false" onclick="btnClicked" />
In the code behind:
protected void btnClicked(object sender, EventArgs e)
{
iframe1.src="an http link";
//do not try set src to www.google.com because they are blocking Iframe
}
Related
I have a webpage containing one ASP.NET file upload control and a button to upload the file to server. The existing code looks like below.
<div runat="server" style="width: 110%">
<asp:FileUpload ID="fileUpload" runat="server" />
<asp:Button ID="BtnFileUpload" runat="server" OnClick="BtnFileUpload_Click" Text="Upload" />
</div>
But our client don't want to see the default look and feel of a standard file upload control. He wants us to add another button and wrap the file upload control with the button, so that whenever user clicks on the button, file upload dialog window opens.
Thanks
you cna do that using jquery you can set fileupload visiblity as none and can open fileuploader from button click like
<div runat="server" style="width: 110%">
<asp:FileUpload style="display:none" ID="fileUpload" runat="server" />
<asp:Button ID="BtnFileUpload" runat="server" onclick="$('#fileUpload').trigger('click'); return false;" OnClick="BtnFileUpload_Click" Text="Upload" />
</div>
you need to reference of jquery for this.
In addition to #Kevin Shah's solution, I got it working this way:
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="BtnFileUpload" runat="server" OnClientClick="$('#ContentPlaceHolder1_FileUpload1').trigger('click'); return false;" Text="Upload" />
My Webform is inside a MasterPage, so I had to look at "View source" while debugging in Chrome to get the correct element ID ContentPlaceHolder1_FileUpload1 instead of just FileUpload1
i want event to fire when selection of radio button list change. but it fire when i click on another button. not on selected index changed.
please note i'm also using bootstrap. without bootstarp it is working
my code is as follow.
Source Code
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
RepeatDirection="Horizontal" BorderStyle="None" CellPadding="5"
CssClass="col-xs-pull-12">
<asp:ListItem Selected="True">All User</asp:ListItem>
<asp:ListItem > SpeciFic Users</asp:ListItem>
</asp:RadioButtonList>
Code behind
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("hi");
}
Also try displaying the list item to find out whether the event is firing or not.
Check out this link, it has a clear definition with an example...Click here
<link href="css/bootstrap-3.3.5.min.css" rel="stylesheet" />
<%--<script src="js/bootstrap-3.1.1.min.js"></script>--%>
2 things for me:
Removed script (unsure if versioning made the difference) the css file made no difference) duh
Needed a separate method to call ( i had nearly all postback events calling the same method ~ 13 controls) (also unsure if every radio control needs their own callback method or not)
.aspx
<div id="rdoSelectOptionsList" class="btn-group" data-toggle="buttons">
<asp:RadioButton ID="rdoShow" GroupName="rdoSelectOptions" runat="server" Checked="true" CssClass="btn btn-default" Text="Show all" />
<asp:RadioButton ID="rdoHide" GroupName="rdoSelectOptions" runat="server" CssClass="btn btn-default" Text="Hide all" />
<asp:Label ID="lblRdoSelectOptions" runat="server" CssClass="form-control-static"/>
</div>
script
$("#rdoSelectOptionsList :radio").each(function () {
if ($(this).is(':checked')) {
$(this).parent().addClass("active");
}
});
I have a repeater and it has a column of linkbuttons in it. I want to add those linkbuttons to targetcontrolid but it failed because they are in the repeater. So i create an additional invisible button like this :
<asp:Button ID="btnFakePopUp" runat="server" Text="" visible="false"
onclick="btnFakePopUp_Click"/>
And in i tried to link the linkbutton to the invisible button in this code :
protected void lbtnPosition_Click(object sender, EventArgs e) {
btnFakePopUp_Click(sender, e);
}
protected void btnFakePopUp_Click(object sender, EventArgs e)
{
popupJob.Show();
}
And this is my modalpopupextender code (my prefix is asp: so dont get confuse) :
<asp:ModalPopupExtender ID="popupJob" runat="server" PopupControlID="panelPopup" CancelControlID="popupClose" TargetControlID="btnFakePopUp"
Drag="true" PopupDragHandleControlID="panelPopup">
</asp:ModalPopupExtender>
<asp:Panel ID="panelPopup" runat="server" BackColor="#ebf0ff" Width="300px">
<div>
test<br />
<asp:Button ID="btnSave" runat="server" Text="Save" />
<asp:Button ID="btnApply" runat="server" Text="Apply" />
<input id="popupClose" type="button" value="Close" />
</div>
</asp:Panel>
The problems are :
1. The panelpopup is always shown...(it should be hidden, and only be shown when the user click the link button)
2. Nothing happened when i tried to click the link button (the panelpopup should be shown)
Thank you :D
For a btnFakePopup invisible you could set the display:none with CSS
example:
<asp:ImageButton ID="btnFakePopUp" runat="server" style="display: none"></asp:ImageButton>
I don't understand why, but setting btnFakePopUp visibility to true corrected the problem. Now my modalpopupextender is running smoothly.
I have created Website. After I login When I hit enter key for add Product, my Website just kick me out.? I dont have problem with adding my cart with mouse click. Does Any One have same Issue or Any suggestion ..
You need to add your controls inside an ASP:Panel and make your AddProduct Button as Default Button:
<asp:Panel ID="panel1" runat="server" DefaultButton="btnAddProduct"">
//Your Other Stuff
<asp:Button ID="btnAddProduct" runat="server" onclick="btnAddProduct_Click"/>
</asp:Panel>
This will Fire AddProduct Button when you hit enter.
Regards
Here is another approach I found here - if you don't want to add a panel
<asp:Button ID="btnDisableEnter" runat="server" Text=""
OnClientClick="return false;" style="display: none;" />
<form id="form1" runat="server" DefaultButton="btnDisableEnter">
If you are using Master Page in asp.net C# and if you are using a button for logout, please type in Button:
<asp:Button ID="btn" runat="server" Text="logout"
UseSubmitBehavior="false" />
Use UseSubmitBehavior="false" in your master page. That's how my problem was solved.
I have an ajax panel (actually it' a Rad Ajax Panel - the behavior is similar to an Ajax Update Panel with everything in the ContentTemplate section and no Triggers), with an image button (asp:ImageButton) and a button (asp:Button).
I notice that they behave differently - the image button advances to postback (Page_Load and Button_Click server functions), when the button doesn't!
How can I achieve this behavior with the Button too? (Replacing the Button with an ImageButton solved the problem... Is there a way to maintain the Button and have the ImageButton's behavior?)
This is what my code looks like (two buttons, two click functions, and two client click functions):
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div style="width: 800px;">
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function validateSave() {
// ...
return true;
}
function validateAdd() {
// ...
return true;
}
</script>
</telerik:RadScriptBlock>
<asp:Panel ID="Panel1" runat="server" Visible="false">
<fieldset>
<legend>New item</legend>
<%--..........--%>
<asp:ImageButton ID="Button4" runat="server"
ImageUrl="~/App_Themes/ThemeDefault/images/add.gif"
OnClientClick="return validateAdd();"
OnClick="Button4_Click" />
</fieldset>
<%--..........--%>
<asp:Button ID="Button2" runat="server"
OnClientClick="return validateSave();"
Text="Save" ToolTip="Save" OnClick="Button2_Click" />
</asp:Panel>
</telerik:RadAjaxPanel>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
</div>
UpdatePanels can often be problematic with Buttons. An easy thing that you can do is move the Button out of the UpdatePanel. After all, the more contents in your UpdatePanel, the slower the asynch postback will be.