For some reason, this code isn't working:
Code-Behind
protected void btnNote_Clicked(object sender, EventArgs e)
{
DevExpress.Web.ASPxPopupControl.ASPxPopupControl notePopup = (DevExpress.Web.ASPxPopupControl.ASPxPopupControl)Master.FindControl("TaskBar").FindControl("pcNote").FindControl("notePopup");
notePopup.ShowOnPageLoad = true;
}
.aspx (event)
<asp:Button ID="btnNote" runat="server" Text="Add Note" OnClick="btnNote_Clicked" />
I need to write a function that takes this popup control ('notePopup') and displays it, and I believe this is supposed to work, but for some reason, once the page is reloaded, there is no popup.
#Jordan, try to add the ASPxPopupControl inside the same MS UpdatePanel. In this case, I believe everything will work properly. What are your results?
I figured it out myself, although what I'm doing now I'm 100% sure I already did, and I'm not sure what else could have changed that affected my results since then, so I'm closing the question.
Related
I am sorry I can't solve what must be simple to everyone else even after reading so many posts. Simply stated... I have an ASP webpage I created in VS2010 and when the user clicks the 'Send Email' button, I want to change the button either using JQuery then calling my code-behind to do the actual send. Alternatively, I want the C# code behind to change the button text while it is in the process of sending so the user knows to hold on.
I am new to JQuery and still pretty new to C#. My website is www. themilwaukeehandcenter.com. If you click the contact us... this is where I want the code. I have tried
$("ContactUsButton").click(function () {
ContactUsLabel.Text = "Processing";
});
on the main page. I have also tried
protected void ContactUsButton_Click(object sender, System.EventArgs e)
{
ContactUsLabel.Text = "Sending... Please Wait";
ContactUsLabel.Refresh();
I know this should be simple but hours later.... reading so many posts later.... I feel no farther. I can't quite figure out how the JQuery onclick and the ASP onclick interact. I also don't know why C# flags the Refresh() as not valid. Any help welcome.
I actually placed a ContactUsLabel on the form too when I couldn't get the ContactUsButton to do what I intended. I am too knew to understand what you mean by 'How have you declared your button, but this is the code that creates it:
<asp:Button ID="ContactUsButton" runat="server"
OnClick="ContactUsButton_Click" Text="Send Email" Width="120px"/>
<asp:Label ID="ContactUsLabel" runat="server" Text="" Width="120px">
</asp:Label>
Your WinForm Code:
<asp:button id="ContactUsButton" runat="server" onclick="ContactUsButton_Click" cssClass="myButton" text="Contact Us" />
On submit use the jQuery script to change button text.
$(document).ready(function() {
$('.myButton').click(function(){
$(this).attr('value', 'Processing...');
});
});
View in fiddler: view
Finally at the server side:
protected void ContactUsButton_Click(object sender, System.EventArgs e)
{
ContactUsButton.Text = "Thank You";
}
I have one aspx page where I need to validate some fields, I made this validation on C# code, but there wasn't working.
So I tried put a simple code only to discover what was the problem, so I realized that didn't matter the code, if I run a ScriptManager.RegisterStartupScript or a ScriptManager.RegisterClientScriptBlock, my C# code doesn't work.
Here is an example:
protected void btnBuscar_Click(object sender, EventArgs e){
this.lblValidarEmpresa.Visible = false;
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "script", "AplicarMascara();", false);
}
The function AplicarMascara() applies a data mask on a text field.
Do you know how solve this problem? Or any other way to apply this mask without use ScriptManager?
Thanks.
On the first sight, try to change last parameter (addScriptTags) to true.
It looks like you're trying to execute javascript code when the button is pushed and things are getting complicated with the use of the updatepanel. Have you considered triggering "AplicarMascara" using the onclientclick property of btnBuscar? You didn't post your code for the button definition but here's a sample of what it should look like:
<asp:Button id="btnBuscar" OnClientClick="AplicarMascara" runat="server" />
I'm trying to have a RadNotification pop up in an event handler in my C# code. I tried something similar to this:
The markup,
<asp:button> ... OnClick="OnClick"</asp:button>
and the CodeBehind,
protected void OnClick(...) {
new RadNotification().Show("Some text");
}
But that doesn't work. The Telerik documentation doesn't seem to have much info on creating these notifications in a CodeBehind.
Thanks
This works for me...
Markup
<telerik:RadNotification ID="RadNotification1" runat="server" VisibleOnPageLoad="False" Width="300px" Height="100px" EnableRoundedCorners="true" EnableShadow="True" Title="My Notification" Position="Center" TitleIcon="none" />
<telerik:RadButton runat="server" ID="MyBtn" Text="Show Notification" OnClick="MyBtn_Click" />
Code Behind
protected void MyBtn_Click(object sender, EventArgs e)
{
RadNotification1.Show("Some text");
}
Modify the RadNotification attributes as necessary.
Cheers
When creating controls dynamically in ASP.NET WebForms, you must:
add them to the form (or a container in it), which you do not. It is also adviseable that you provide them with IDs
re-create them upon subsequent postbacks if they are going to be needed
This is not something specific to the Telerik controls, but it also applies to any control. Try adding a textbos with a preset text like this to see the problem.
Thus, Scotty's answer where the notification is simply declared in the markup is perhaps the most straightforward solution.
I have a list of asp:LinkLabels which are contained a repeater.
I have a button that says "Get Started" when a user clicks on this button, I want it to execute the first item in the repeater.
I have this code working fine in Chrome, but not in any other browser:
<asp:Button ID="SubmitInfo" runat="server" Text="Save and Get Started" Width="218px" OnClientClick="__doPostBack('rptList$ctl01$Label15','')" CssClass="submit-button-huge" OnClick="SubmitInfo_Click" />
Is there a way to do this server side without using the __doPostBack javascript?
Is there anything glaringly wrong here?
Difficult to answer without your whole code. I'll assume your LinkLabels are LinkButtons named "lb1", and you use commandName and CommandArgument, Repeater_ItemCommand
I would try something like this in the repeater.ItemCreated
private void Repeater_ItemCreated(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
{
var lb = (LinkButton)e.Item.FindControl("lb1");
if(IsPostBack && e.Item.ItemIndex==0)
{
SubmitInfo.Click+= (source,args)=>Repeater_ItemCommand(lb,new RepeaterCommandEventArgs(e.Item,lb,new CommandEventArgs(lb.CommandName,lb.CommandArgument)));
}
...
Hope this will help
i have save button in around 150 pages. when ever the user clicks on save button i should disable the button after the click. so that user does not keep clicking on save button again.
protected void Button1_Click(object sender, EventArgs e)
{
// right now once the user clicks the save button
Button1.Enabled = "false"
}
right now i am doing like this. is there any better solution u can provide me to improve codeing here would be great.
thank you
I think the best option to accomplish this is using javascript. If you are using jQuery (which I can even start to recommend enough) then you can put the javascript in your masterpage. You just need to find a way to create a selector for your save buttons. Like this:
$(document).ready(function(){
$('.saveButton').bind("click", function(e) {
$(this).attr("disabled", "true");
return true; //causes the client side script to run.
});
});
In this example, I assumed that all the save buttons would have the css class ".saveButton", but you can find your own way to select the button.
Cheers!
You can also try disabling it via Javascript.
You need to use JavaScript to alter the link once it's clicked to prevent future click handling, before allowing the page to proceed with the postback. A naive attempt would be,
<asp:LinkButton runat="server" id="button" OnClientClick="this.href='#'">
Click - doesn't quite work
</asp>
This successfully prevents successive clicks from triggering the postback, but it also prevents the first click from triggering the postback. A little more logic is required to make this work correctly. In the codebehind, I grab the actual postback JavaScript snippet and work it into some logic.
protected void Page_PreRender(object sender, EventArgs e)
{
button1.OnClientClick = string.Format(
"if(this.getAttribute('disabled')) return false; {0}; this.setAttribute('disabled','disabled'); return false;",
Page.ClientScript.GetPostBackEventReference(button1, null));
}
In the HTML template:
<asp:LinkButton runat="server" id="button" >
Click - does not allow multiple postbacks
</asp>
You can spruce this up with some CSS, and at that point I would advise including jQuery, so your code is more concise (due to its command chaining).
What you have to do is use some JavaScript and disable it when its clicked on the client side.
That click event fires on a postback.
Simplest way of attaching javascript to disable the button after user click would be this (in page onLoad event):
myButton.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnSave, null) + ";");
But if button is repeated on many pages, you can maybe create nested master page and put save button there, or inherit you page from class that implements this disable functionality. Also, you can "scan" for control you want to disable after click!