I have some asp;View controls in asp:MultiView control. The strange problem is, when I move from View3 to View4, some controls from the View3 are visible within View4. Why ? It's the first time I occur that problem
<asp:View ID="View3" runat="server">
<br />
<label id="Label1">Test</label>
<br />
<asp:Button ID="RejectButtonGrid" runat="server" Text="Erase1" OnClick="RejectButton_Click" />
<asp:Button ID="AcceptButtonGrid" runat="server" Text="Accept" OnClick="AcceptButton_Click" />
</asp:View>
<asp:View ID="View4" runat="server">
<asp:Button ID="RejectButtonDuplicates" runat="server" Text="Erase2" OnCommand="RejectButtonDuplicates_Command"/>
<asp:Button ID="AcceptButtonDuplicates" runat="server" Text="Accept" OnCommand="AcceptButtonDuplicates_Command"/>
<br />
<asp:Button ID="BackButton" runat="server" Text="Go back" OnClick="BackButton_Click"/>
</asp:View>
Buttons from View3 are visible on View4
The markup seems to be ok, I presume views 1 and 2 are working fine? Looking at the code I would expect view 3 to show two buttons "Erase1" and "Accept", and then for view 4 it should show two buttons with "Erase 2" and "Accept"...?
Why are the buttons in view 4 using the 'OnCommand' attribute instead of 'OnClick' as they do for view 3?
Maybe the controls are cached...
try cleaning the folder 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET' Files and try again...
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 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 a question about AJAX MultiHandleSliderExtender. Code is following:
<form runat="server" id="myForm">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" CombineScripts="false" />
<asp:TextBox ID="strMinModTB" runat="server" Style="display:none;" Text="80" />
<asp:TextBox ID="strCurModTB" runat="server" Style="display:none;" Text="100" />
<asp:TextBox ID="strMaxModTB" runat="server" Style="display:none;" Text="160" />
<asp:TextBox ID="strSlider" runat="server" Style="display:none;" />
<asp:MultiHandleSliderExtender ID="strModMultiSlider" runat="server"
BehaviorID="strModMultiSlider"
TargetControlID="strSlider"
Minimum="0"
Maximum="300"
Length="600"
EnableHandleAnimation="true"
EnableKeyboard="false"
EnableMouseWheel="false"
ShowInnerRail="true"
ShowHandleDragStyle="true"
ShowHandleHoverStyle="true">
<MultiHandleSliderTargets>
<asp:MultiHandleSliderTarget ControlID="strMinModTB" />
<asp:MultiHandleSliderTarget ControlID="strCurModTB" />
<asp:MultiHandleSliderTarget ControlID="strMaxModTB" />
</MultiHandleSliderTargets>
</asp:MultiHandleSliderExtender>
<asp:Label ID="sliderLabel" runat="server" Visible="true"></asp:Label>
</form>
Now what I want to do is to lock positions of outter handles and allow only the middle one to be dragged in range from the left hanle to the right one thus changing the value in asp:Label (ID="sliderLabel").
I've tried readOnly="true" attribute on TextBoxes but with no result. There is also IsReadOnly Extender property but that blocks all handles.
Also when I add the BoundControlID property (containing ID of label) to the Extender it stops working (all handles on 0 position and I cannot drag them)
Is there a way around this or am I missing something?
Thank you for replies :)
You don't need a BoundControlID for the MHSE do you?
Also, could you not add a class to each Handle and then fix the outer handles positions using CSS?
See below for code example.
ASP Code
<asp:MultiHandleSliderExtender ID="strModMultiSlider" runat="server"
BehaviorID="strModMultiSlider" TargetControlID="strSlider"
Minimum="0" Maximum="300" Length="600"
EnableHandleAnimation="true" EnableKeyboard="false"
EnableMouseWheel="false" ShowInnerRail="true"
ShowHandleDragStyle="true" ShowHandleHoverStyle="true">
<MultiHandleSliderTargets>
<asp:MultiHandleSliderTarget ControlID="strMinModTB" HandleCssClass="handle_outer"/>
<asp:MultiHandleSliderTarget ControlID="strCurModTB" HandleCssClass="handle_inner" />
<asp:MultiHandleSliderTarget ControlID="strMaxModTB" HandleCssClass="handle_outer"/>
</MultiHandleSliderTargets>
</asp:MultiHandleSliderExtender>
CSS Code
.handle_outer
{
//Code to Fix Handle in Place
}
.handle_inner
{
}
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.
Searching on google, i deffinitly can't find a non-javascript way to show and hide my panel/updatepanel.
I do have panels and updatepanels, I want to show/hide them on the fly, after a button click, preferably without javascript, or if so, with jQuery.
All the examples I found consumes a lot of code and honestly I don't want to crap out my code just because of this.
Ideas?
It doesn't really take a lot of code with jQuery:
<input type="button" onclick="$('#blah').toggle();" />
<someelement id="blah"></someelement>
For ASP.NET (modified from your code):
<asp:Button ID="btnSubmit" runat="server" CssClass="button-login" OnClientClick="$('#login').toggle();" />
You could as well use the multi view and a couple of views inside. By doing this you can use a button control to choose which view (panel) is to be displayed. The code below will toggle between two views containing two image tags.
ASP.NET Form (HTML)
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
<div>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<imgage = "my picture"> //add image tage here
</view>
<asp:View ID="View2" runat="server">
<imgage = "your picture"> //add image tage here
</view>
</asp: Multiview>
</div>
CODE BEHIND
Private button click toggleImageView
If multiview1.ActiveViewIndex=0 then
multiview1.ActiveViewIndex=1
ElseIf
multiview1.ActiveViewIndex=1 then
multiview1.ActiveViewIndex=0
EndIf
You may also use a list box to select which view to display on the fly like this
But note that your control o select which view to be displayed should be outside the multiview control and also be rendered on page load
<asp:DropDownList ID="DropDownList1" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
runat="server" AutoPostBack="True">
<asp:ListItem Value="0">View 1</asp:ListItem>
<asp:ListItem Value="1">View 2</asp:ListItem>
</asp:DropDownList><br />