how to change the title of the confirmation in asp - asp.net

I have added a confirmation dialog before deleting an item in asp.net web page.
Here's my coding.
OnClientClick="return confirm('Are you sure you want to delete this Contact Record?');"
It gives the default title as "The page at local host:49456 says:"
I need to change that default title of this dialog box.My default browser is Google chrome.
Can somebody help me???
Thanx in advance.

Give the Header needed like this.
OnClientClick="return confirm('Are you sure you want to delete this Contact Record?','Your Title');

note: when tweaking page title - can't change it here if the aspx page sets it to "". so, in the .aspx page set it to something other than empty string; e.g.:
Page.Title = "Some New Title";

Related

How to redirect to another page with using a function on that page with asp link

I am new to asp.net. So just learning everything step by step.
I have created a web project with the template.
On Page one, I have a button and a textbox with no action defined yet.
On Page two I have a button and a textbox and I also have db connections works from the button.
What I want to do is, if user writes something and click button on first page, I want to go page 2 and acts as clicked button.
I want to run some action on page two with parameter from page on.
I think this is possible with redireciton mechanism
I will post the code here. can anyone help me . I may be wrong as I am new to this language.
I can do it with a button but I want to do it with a asp link
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="BringPage2" />
Right now this is a link but I want to make it a button
<p>Bring Page 2 »<input id="txtBoxAlan" name="txtBoxAlan" type="text" />
Instead of redirect, I just used href as href="Default1.aspx"

Acessing Items on a Masterpage from a Child page

I have a <ASP:Label ID="lblDashboardLink" runat="server" /> located on a MasterPage named MasterBase.
From a page using this MasterPage, how can I access this label or any other items I need?
'VB.NET
'(From the child .aspx page)
Master.FindControl("lblDashboardLink"). <-- but don't see an option to change URL
I've been googling and I keep finding this same method, but it's focusing more on User Controls it looks like... Can anyone guide me in the right direction here?? I'm so used to MVC!
Master.FindControl("lblDashboardLink") always returns a Control (see MSDN). So all you have to do is cast it to Label. Then you may access any properties of a Label. Anyway there is no URL property in a label...
CType(Master.FindControl("lblDashboardLink"), Label).Text = "your value"
Try this:
CType(Master.FindControl("lblDashboardLink"), Label).Text = "some url"

link button property to open in new tab?

In my application I have some link buttons there but when I right click on them I cannot (they are in disable mode) find the menu items Open in new tab or Open in new window.
How do I show those menu items?
Code example:
<asp:LinkButton id="lbnkVidTtile1" runat="Server" CssClass="bodytext" Text='<%#Eval("newvideotitle") %>' />
From the docs:
Use the LinkButton control to create a hyperlink-style button on the Web page. The LinkButton control has the same appearance as a HyperLink control, but has the same functionality as a Button control. If you want to link to another Web page when the control is clicked, consider using the HyperLink control.
As this isn't actually performing a link in the standard sense, there's no Target property on the control (the HyperLink control does have a Target) - it's attempting to perform a PostBack to the server from a text link.
Depending on what you are trying to do you could either:
Use a HyperLink control, and set the Target property
Provide a method to the OnClientClick property that opens a new window to the correct place.
In your code that handles the PostBack add some JavaScript to fire on PageLoad that will open a new window correct place.
Here is your Tag.
<asp:LinkButton ID="LinkButton1" runat="server">Open Test Page</asp:LinkButton>
Here is your code on the code behind.
LinkButton1.Attributes.Add("href","../Test.aspx")
LinkButton1.Attributes.Add("target","_blank")
Hope this will be helpful for someone.
Edit
To do the same with a link button inside a template field, use the following code.
Use GridView_RowDataBound event to find Link button.
Dim LB as LinkButton = e.Row.FindControl("LinkButton1")
LB.Attributes.Add("href","../Test.aspx")
LB.Attributes.Add("target","_blank")
try by Adding following onClientClick event.
OnClientClick="aspnetForm.target ='_blank';"
so on click it will call Javascript function an will open respective link in News tab.
<asp:LinkButton id="lbnkVidTtile1" OnClientClick="aspnetForm.target ='_blank';" runat="Server" CssClass="bodytext" Text='<%# Eval("newvideotitle") %>' />
This is not perfect, but it works.
<asp:LinkButton id="lbnkVidTtile1" runat="Server"
CssClass="bodytext" Text='<%# Eval("newvideotitle") %>'
OnClientClick="return PostToNewWindow();" />
<script type="text/javascript">
function PostToNewWindow()
{
originalTarget = document.forms[0].target;
document.forms[0].target='_blank';
window.setTimeout("document.forms[0].target=originalTarget;",300);
return true;
}
</script>
LinkButton executes HTTP POST operation, you cant change post target here.
Not all the browsers support posting form to a new target window.
In order to have it post, you have to change target of your "FORM".
You can use some javascript workaround to change your POST target, by changing form's target attribute, but browser will give a warning to user (IE Does), that this page is trying to post data on a new window, do you want to continue etc.
Try to find out ID of your form element in generated aspx, and you can change target like...
getElementByID('theForm').target = '_blank' or 'myNewWindow'
When the LinkButton Enabled property is false it just renders a standard hyperlink. When you right click any disabled hyperlink you don't get the option to open in anything.
try
lbnkVidTtile1.Enabled = true;
I'm sorry if I misunderstood. Could I just make sure that you understand the purpose of a LinkButton? It is to give the appearance of a HyperLink but the behaviour of a Button. This means that it will have an anchor tag, but there is JavaScript wired up that performs a PostBack to the page. If you want to link to another page then it is recommended here
that you use a standard HyperLink control.
It throws error.
Microsoft JScript runtime error: 'aspnetForm' is undefined
<asp:LinkButton ID="LinkButton1" runat="server" target="_blank">LinkButton</asp:LinkButton>
Use target="_blank" because It creates anchor markup. the following HTML is generated for above code
<a id="ctl00_ContentPlaceHolder1_LinkButton1" target="_blank" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$LinkButton1','')">LinkButton</a>

Asp.net regularexpressionvalidator fires even when CausesValidation="false"

I have a regularexpression validator which validates a valid email. I have two buttons on my form. Submit and undo.
On undo, we are reverting the page state to default
submit has it validationgroup set while undo doesnot have any validationgroup and CausesValidation="false".
Now when i navigate to page and enter invalid emailaddress,i directly click undo. the validator fires and stops my page from posting.however if i press tab and navigate to other control and then click undo,the validator shows error message but posts back and furthur proessing is done.
This is very strange and i want the page to postback without any error message when i click undo.how to achieve it.
<tec:ThemedImageButton runat="server" ID="imgbtnSave" OnClick="imgbtnSave_Click"
ValidationGroup="CustomerGroup"/>
<tec:ThemedImageButton runat="server" ID="imgbtnCancel" CausesValidation="false"
OnClick="imgbtnCancel_Click" />
These are normal image buttons with added themes.CustomerGroup is the validation group for my textbox and regularexpressionvalidator
Are you possibly clicking the undo whilst your focus is still within the email textbox? If so, perhaps the issue is that the initial blur event of the textbox is firing which in turn is calling the email validator and preventing the click / submission.
The first thing to try is to make sure you can enter an invalid email address, move the focus onto a completely different area of the page and then press undo to determine if this is the cause.
Double check your settings.
You might want to check the code behind to make sure you are not overwriting the control settings there. For example, in code, you might have the CausesValidation set to "True" or something like that.
Until you post more information you could do the following in your Undo button:
<asp:Button ID="btnUndo" runat="server" Text="Undo"
OnClientClick="Page_ValidationActive = false;"
OnClick="btnUndo_Click" />
I don't recommend this as it might solve your problem but really doesn't explain what is wired up incorrectly but the Page_ValidationActive = false; will disable all client validation on your page.

ASP.Net PostbackURL doesn’t work if I put in Javascript Validation

I would like to share my problem with you in detail.
1) I have a textbox and a button in my page consider it as home.aspx
2) I have written the code like this:
<asp:Button id="btnSubmit" runat="server" Text="Submit" PostBackUrl="~\search.aspx"
OnClientClick="validate();" />
3) I have to check wheteher the textbox is null. If not null i want to redirect to search.aspx as given in the postbackurl.
4) Using java script i have validated;
function validate()
{
if(document.getElementById('txtCity').value!='')
{ alert('please enter the city to search'); returnn false;}
}
5) If the textbox is null. It alerts to enter the city. If not the page remains. It is not redirected to the search page.
I hope you can..
Kumar,
You will need to provide much more information then this.
A blind guess at what you are asking, is that you have a button on your page that causes validation. However, also on your page you have a linkbutton that should not cause validation, but just direct to the PostBackUrl.
You can accomplish this one of two ways:
1. Add a validation group to your button and all the controls it should validate.
2. On your LinkButton, add CausesValidation="false" to your declaration.
If these blind guesses are not helpful, please provide much more information.

Resources