confirm ,ok, cancel

hi

I am using 2 buttons named edit and update. in asp.net and c#.

There is one textbox control named "txtSelectionsNew".

there is 1 datagrid.,it is having bound column edit i.e push button.

when i click edit button in datagrid,the corresponding fields will display into textfiled named txtselectionsnew.

at that time i am making readonly for this text control true.

after clicking on edit,i'll change that textbox control and i'll do update by clicking on update.for updation i wrote one function.

when i click on update button,confirm box will show ok,cancel.

for this i wrote javascript code.like

<script type="text/javascript">

function confirmDelete() {

return window.confirm("are you sure?");

}

in the page code, i wrote like :

btnUpdateAttribute.Attributes.Add("OnClick", "return confirmDelete()");

everything is ok,when i click ok,that update is running.

but when i want 2 click cancel for that update button,my textbox control readonly should be false.how to change this textbox readonly from  true to false,where should i change.

plz help me.

1
swapprose
5/2/2006 10:35:38 AM
asp.net.client-side 24353 articles. 2 followers. Follow

13 Replies
1762 Views

Similar Articles

[PageSpeed] 59
Get it on Google Play
Get it on Apple App Store

Here is a function that works for all browsers:

function readonlyC( status )
{
    var r = document.getElementById( "txText" );
    //r.readonly = status;
    if( status )
        r.setAttribute( "readOnly", "true" );
    else
    {
        try{
            r.removeAttribute( "readOnly" );
        }
        catch( ex )
        {
           
        }
    }
}



I don't suffer from madness,
I enjoy it every minute of my life
0
Dyno1979b
5/2/2006 1:45:02 PM

When I make readonly false when i click cancel,then updation process is going on when i click cancel also.

wt 2 do?

plz  help me.

0
swapprose
5/3/2006 9:28:05 AM
Can you post the code for .aspx page (put javascript code too if it's
in another file) and tell me exactly what you want to happen. We'll
make this workBig Smile [:D] 

I don't suffer from madness,
I enjoy it every minute of my life
0
Dyno1979b
5/3/2006 9:37:04 AM

i have 2 buttons,edit and update.

click on edit- textboxes readonly true.

after click on update- update function will be executed.and those textboxes should be readonly false.

everything is fine.

when i am writing code for readonly false for that textbox,when i click cancel also,its updating.but that readonly attribute is working properly.

 

in javascript

 

<script type="text/javascript">

function confirmUpdate() {

return confirm("are u sure");

}

</script>

 

in .cs page

-------------

protected

void Page_Load(object sender, EventArgs e) {

btnUpdateAttribute.Attributes.Add(

"OnClick", "return confirmUpdate();");

 

// update click - this function will execute for updation

 

protected void btnUpdateAttribute_Click(object sender, EventArgs e)

{

StoreDataService.ProductAttributesUpdate(int.Parse(TextBox1.Text),txtAttributeNew.Text, int.Parse(ddlAttNewSelectionType.SelectedValue), txtAttNewDesc.Text, int.Parse(lblID.Text), txtSelectionsNew.Text);

LoadAttributes(

int.Parse(lblID.Text));

attemplatesfalse();

btnAddAttribute.Enabled =

true;

}

now tell me where i have to set the txt field read only attribute.

 

thanks,

0
swapprose
5/3/2006 2:49:44 PM
protected void btnUpdateAttribute_Click(object sender, EventArgs e)

{

StoreDataService.ProductAttributesUpdate(int.Parse(TextBox1.Text),txtAttributeNew.Text, int.Parse(ddlAttNewSelectionType.SelectedValue), txtAttNewDesc.Text, int.Parse(lblID.Text), txtSelectionsNew.Text);

LoadAttributes(
int.Parse(lblID.Text));

attemplatesfalse();

btnAddAttribute.Enabled = true;
TextBox1.ReadOnly = true;
txtAttributeNew.ReadOnly = true;
txtAttNewDesc.ReadOnly = true;
txtSelectionsNew.ReadOnly = true;  

}

I don't suffer from madness,
I enjoy it every minute of my life
0
Dyno1979b
5/4/2006 6:47:46 AM

hi

U r not getting wt i mean.

ok leave it.

Thanks,

swapprose.

0
swapprose
5/4/2006 12:07:52 PM
Sorry I didn't get it.

I think I might have an idea about what you're talking. You're saying that even when clicking on cancel the update is made.

That means you're running the update method on postback regardless of the event ( since you're posting back from javascript you have to set manually the event).

In this case you can use a hidden field:
<input type="hidden" id="hAction" value="">

which
doSubmit( action )
{
    document.getElementById( "hAction" ).value = action;
    document.getElementById( "frmForm" ).submit();
}

and you have to set to onclick="doSubmit( 'update' ) " for update action and onclick="doSubmit( 'cancel' ) " for cancel button.

At code behind you will run the update function only if hAction.Value == "update".

Hope this helps and it is about your problem.


I don't suffer from madness,
I enjoy it every minute of my life
0
Dyno1979b
5/4/2006 12:18:56 PM
OF COURSE:
<input type="hidden" id="hAction" value="" runat="server">

in code behind:
protected HtmlInputHidden hAction;

Geeked [8-|]


I don't suffer from madness,
I enjoy it every minute of my life
0
Dyno1979b
5/4/2006 12:19:53 PM

hi

When i click on update button,confirm box will show ok and cancel.If i click on ok,updation made.

 i have 2 capture cancel button in confirmbox when i click on update button,i mean when i click on cancel button,my textbox filed attribute should be set to readonly false.

In this way i can solve,But how 2 capture that cancel when user clicks on cancel button.

Anyway when i click on update,and accepting 'ok' in confirm box,in the corresponding  update function only i am setting my textfield attribute.

so Now u tell me how 2 capture cancel in confirm box.This will makes my problem easy instead of going any other code.

 

Thanks.

 

 

0
swapprose
5/4/2006 1:28:46 PM
Well,
I hope I understood right this time.

javascript confirm function returns true on acceptance ( click on ok button, enter ) and false on cancellation ( click on cancel button, esc).

So
if( confirm( "Question Text" ) )
{
    // do confirm update stuff
}
else
{
    // do cancel update stuff
}



I don't suffer from madness,
I enjoy it every minute of my life
0
Dyno1979b
5/4/2006 2:03:13 PM

hi

 

when i am trying 2 set txtbox attribute only,updations is made when i click on cancel also.

and more over its showing like document.getelemeid.setattribute(-----)  --- is null or not an object.

if i am setting txt attribute,updations is going on for cancel also.

previously i done like this only.

if i won't set any attribute for textbox,then cancel is not doing updation, then its correct.but i wnat 2 set attribute for my textbox .wt 2 do for this problem.

 

Thanks

 

0
swapprose
5/4/2006 2:32:52 PM
I have a request,

can you post the full code for .aspx page and possible for code behind (.aspx page should be enough but to be sure )


I don't suffer from madness,
I enjoy it every minute of my life
0
Dyno1979b
5/4/2006 2:36:30 PM

<%

@ Control Language="C#" AutoEventWireup="true" CodeFile="ProductAttributes.ascx.cs" Inherits="Modules_Admin_ProductAttributes" %>

<%

@ Register Assembly="MagicAjax" Namespace="MagicAjax.UI.Controls" TagPrefix="ajax" %>

<%

@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %>

<h1>Attributes</h1>

<

table class="admintable">

<

tr><td style="width: 1002px; height: 550px">

<ajax:ajaxpanel ID="Ajaxpanel3" runat="server">

&nbsp;<table cellspacing="0" style="width: 675px">

<tr>

<td class="adminlabel" style="height: 22px">

Use a Template

</td>

<td class="adminitem" style="height: 22px; width: 538px;">

<asp:DropDownList ID="ddlAttTemplates" runat="server" OnSelectedIndexChanged="ddlAttTemplates_SelectedIndexChanged" >

</asp:DropDownList>

<asp:Button ID="btnSetTemplate" runat="server" OnClick="btnSetTemplate_Click" Text="Set" />

&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

<asp:TextBox ID="lblID" runat="server" Visible="False"></asp:TextBox>

&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;

<asp:Label ID="Label1" runat="server" Text="product id" Width="76px" Visible="False"></asp:Label></td>

</tr>

<tr>

<td class="adminlabel">Attribute Name</td>

<td class="adminitem" style="width: 538px">

<asp:TextBox ID="txtAttributeNew" runat="server" Width="174px" MaxLength="50"></asp:TextBox></td>

</tr>

<tr>

<td class="adminlabel">

Description

</td>

<td class="adminitem" style="width: 538px">

<asp:TextBox ID="txtAttNewDesc" runat="server" Height="46px" TextMode="MultiLine"

Width="174px" MaxLength="500"></asp:TextBox></td>

</tr>

<tr>

<td class="adminlabel">Selection List<br />

<i>To adjust the price for an item, enter the adjustment in parentheses

next to the selection using "add" for positive adjustment, and "subtract"

for negative. So, to add $5 for an attribute selection, enter "Selection (add $5)".

This value will be parsed so please be sure to use a number!

</i>

</td>

<td class="adminitem" style="width: 538px">

<asp:TextBox ID="txtSelectionsNew" runat="server" Height="159px" TextMode="MultiLine" MaxLength="250"></asp:TextBox>

&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;

<asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>

<asp:Label ID="Label2" runat="server" Text="product attribute id" Visible="False"></asp:Label>

<asp:TextBox ID="TextBox2" runat="server" Width="96px" Visible="False"></asp:TextBox>

<asp:Label ID="Label3" runat="server" Text="template attribute id" Width="80px" Visible="False"></asp:Label>

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Update Template"

Width="108px" />

<asp:Button ID="btnSaveAttTemplate" runat="server" OnClick="btnSaveAttTemplate_Click"

Text="Save Template" Width="102px" />&nbsp;<asp:Button ID="btnDeleteAttTemplate" runat="server" OnClick="btnDeleteAttTemplate_Click" AutoPostBack ="true"

Text="Delete Template" width="105px" /></td>

</tr>

<tr>

<td class="adminlabel">

Selection Type

</td>

<td class="adminitem" style="width: 538px">

<asp:DropDownList ID="ddlAttNewSelectionType" runat="server" OnSelectedIndexChanged="ddlAttNewSelectionType_SelectedIndexChanged" AutoPostBack ="true">

<asp:ListItem Value="1">Single Selection List</asp:ListItem>

<asp:ListItem Value="2">Multi-Select</asp:ListItem>

<asp:ListItem Value="3">User Input</asp:ListItem>

</asp:DropDownList>

&nbsp;&nbsp;

</td>

</tr>

</table>

<asp:Button ID="btnAddAttribute" runat="server" Text="Add" OnClick="btnAddAttribute_Click" />

<asp:Button ID="btnUpdateAttribute" runat="server" Text="Update" OnClick="btnUpdateAttribute_Click" /><br /><br />

<asp:DataGrid ID="dgAtts" runat="server" width="650px" BorderColor="White" BorderWidth="0px" AutoGenerateColumns="False" OnDeleteCommand="DeleteAtt" OnEditCommand="UpdateAtt" OnSelectedIndexChanged="dgAtts_SelectedIndexChanged">

<FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>

<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="Gainsboro"></SelectedItemStyle>

<AlternatingItemStyle ForeColor="Black" BackColor="WhiteSmoke"></AlternatingItemStyle>

<ItemStyle ForeColor="Black" BackColor="White"></ItemStyle>

<HeaderStyle Font-Size="8pt" Font-Names="Verdana" Font-Bold="True" ForeColor="Black" BackColor="LightSteelBlue"></HeaderStyle>

<Columns>

<asp:BoundColumn DataField="productAttributeID" HeaderText="ID"></asp:BoundColumn>

<asp:BoundColumn DataField="AttributeName" HeaderText="Attribute"></asp:BoundColumn>

<asp:BoundColumn DataField="SelectionList" HeaderText="Selections"></asp:BoundColumn>

<asp:ButtonColumn ButtonType="PushButton" CommandName="Delete" Text="Delete"></asp:ButtonColumn>

<asp:ButtonColumn ButtonType="PushButton" CommandName="Edit" Text="Edit"></asp:ButtonColumn>

</Columns>

</asp:DataGrid></ajax:ajaxpanel>

</td>

</tr>

</table>

<script type="text/javascript">

function confirmDelete() {

if( confirm("Are you sure?"))

{

return true;

}

else

{

return false;

}

}

</script>

in .cs page

------------------

 

protected

void Page_Load(object sender, EventArgs e) {

btnUpdateAttribute.Attributes.Add(

"OnClick", "return confirmDelete();");

}

protected void btnUpdateAttribute_Click(object sender, EventArgs e)

{

StoreDataService.ProductAttributesUpdate(int.Parse(TextBox1.Text),txtAttributeNew.Text, int.Parse(ddlAttNewSelectionType.SelectedValue), txtAttNewDesc.Text, int.Parse(lblID.Text), txtSelectionsNew.Text);

LoadAttributes(

int.Parse(lblID.Text));

attemplatesfalse();

btnAddAttribute.Enabled =

true;

}

 

when i am clicking on edit button,i am making some textboxes readonly true.,only one textbox should be readonly

false and add button is disables.

aftet that changing that one textbox,i  click on update,msgbox will show ok and cancel.if i lick on ok ,then all my textboxes readonly false. ,add button is enabled.

upto this point is ok.

when i want 2 cancel that updation,the textboxes should be readonly false,add button also enabled.

when i am trying set attributes like this ,updation is going on bydefault when i click cancel also.

and more over getelementid(-----) is not object or null error is showing.

wt 2 do?

 

 

 

 
0
swapprose
5/11/2006 12:35:50 PM
Reply:

Similar Artilces:

Modal Popup on Client-Side
Hello, Is it possible to determine in the client API that a user clicked the OK/Cancel option, either via enumeration or boolean property?  I'm accessing this on the client only, and am trying to figure out how I can tap into this to perform a client action. Thanks.Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). You can do it by handling the following properties... OnOkScript - Script to run when the modal popup is dismissed with the OkControlID...

Perform JavaScript Client Side Confirmation from a VB.NET DataGrid
Hi, I when I delete an item from the database through a Datagrid I want to get a messagebox popingup to give me the choise to Confirm it...in case I clicked the wrong item....the way it works now it just deletes it....can any one help me with an Example I have no Idea how to do this...I found an article in C# but it didnt help me at all. here is my source code <asp:DataGrid ID="dgCustList" Runat="server" AutoGenerateColumns="False" DataKeyField="id" AlternatingItemStyle-BackColor="#F6F6F6" HeaderStyle-BackColor="#C4B58E" CellSpacing="0" CellPadding="2" GridLines="Vertical" Width="100%"...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

communication between client side(java script) and server side in .net project
I have a question which is, when building a .net project, we are able to use server side code and client side code(java script). How do they communicate? Thanks Client Side coding works with the WebBrowser. So when ever you write client side code you have to keep browser compatability in your mind and you have to code. Server Side code works with Web Server (IIS) and it's ASPNET ISAPI's. The won't directly communicate with each other. But using AJAX you can all server side code from Client Side! Example article on Ajax@ http://www.devarticles.com/index2.php?option=content&task=...

Firing server side validation & Client side confirm with a single button..
Hi All, I have a "Update" asp button. onclick of the button i need to check the server side validations like:if (!IsValidEmail(ctrlEmailAddress.TextBoxControl.Text.Trim())) {MessageBox.Show("Enter valid email address"); validateCheck = false; } After completion of this type of validations, i need to fire one javascript confirmbox saying "Are you sure you want to update this order?" with "Yes/No" options. All these things needs to be done in a single button click. Can any one help me to acheive this ..requirement?  -HemanthPlease rem...

.NET for client side?
Is this the idea of "Atlas" but using JavaScript rather than another technology? Atlas's goal is to abstract various browser implementations of DOM API and to ease out the developer's job to write rich client applications. Atlas hence makes use of the existing all-browser supported JavaScript to achieve this. Thanks for your reply.Let me convey my idea differently: I would like to author client side code using a class system. I recognise that Atlas is a technology for producing JS code, much in the same way that ASP.NET produces HTML for the browser.Will Atlas be m...

Client-Side Confirm
I'm stuck.I have a asp:LinkButton which calls a code-behind sub-procedure when clicked. I need to add a client-side javascript-type confirm on the client-side to make sure this is what the user wants to do.How can I pull this off?If I create a java script function to place the confirm statement, how do I call the code-behind procedure from java-script?Any help on this would be greatly appreciated...  Hi, you can simply add OnClientClick="if(!confirm('Are you sure?')){return false;}" to the LinkButton markup. Don't confuse client-side with server-side. Your...

Cancel Timer on client side
Hi,  Can an AJAX timer be canceled or stopped after is was rendered to the client (from JS of course)? Thanks, Uzi You can call _stopTimer method of Timer contrlol from javascript. It is meant to be a private function.    var timer = $find('Timer1');//Give the timer control id used in server contrlol timer._stopTimer(); Anish DevasiaMCP,MCAD--------------------------------------------------- Thanks Please mark this thread as Answered/Resolved if you have got the solution.Anish DevasiaMCP,MCAD--------------------------------------------------- D...

List of client side function of extenders and controls for client side
Hello All,I am using AJAX control toolkit for my current project. Now I need to find out what client side functions I can call on an extender. Lets say I am using a PopControlExtender. Now I want to show the popup from a JS funtions.If I can do a guess then it would be something like this$find('ppce').show();From where I can find what client side functions I can call on those extensders. This is really a frusterating thing. I learn about extenders only from Learn tutorials, no help here and there. Can anybody please tell me where are documentations about all the extenders in the tool...

OK and Cancel option (confirmation)
I want to do provide ok and cancel option with ASP.Net button. Scenario : User will click on the button "Get Price". I will call some procedures / database call and manipulate some data and will calculate price. I want to show messagebox to user say ex.  "The calculated price is: 12.34. Do you want to proceed?". with OK and Cancel option. If user press OK then proceed with further operation and cancel will not do anything.  Please suggest me the code. Thanks   <asp:Button ID="myButton" runat="server" Text="Get Price"...

Side by Side Execution of .net v1.1 and .net v2.0
Hi i am new bie to asp.net 2.0.Till date i have been developing projects using VS.Net 1.1 and now i hv decided to upgrade to new version 2.0.Now i want to run and develop my projects using any of the versions as desired.My question is that can i install vs 2.0 without updating the previous version and will i be able to develop and run my applications in any of the versions as desired.i have been known that we can run these versions side by side(i.e. one application can use 1.1 and other 2.0),but can we do side by side development as well(i.e. one application can use 1.1...

Client Side Conditional Delete Confirmation
- Using VS 2003 datagrid  Is there a way to look at the data of a row in the ItemCreated event so I can conditionally create the javascript for a delete button in my datagrid?  All of the examples I see add the onclick attribute in the ItemDataBound event but when I put it there, it never fires.  I have viewed the source and the script shows up appropriatly but just never displays the dialog when I put it in the ItemDataBound event.  I have the following in the ItemCreated event:if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item...

Web resources about - confirm ,ok, cancel - asp.net.client-side

Facebook Confirms Streamlined Post Scheduling, Announces Easier Photo Uploading For Page Admins
Facebook officially announced the improvements to the post-scheduling process that began leaking out last week, as well as an easier way for ...

4th XMRV Study Fails to Confirm Association with CFS - Facebook
The CFIDS Association of America hat eine Notiz mit dem Titel 4th XMRV Study Fails to Confirm Association with CFS geschrieben. Du kannst den ...

Slide Confirms Cuts to Ad Sales Staff, Continues to Shift Focus
Late last month, we reported that direct to consumer virtual goods sales were now accounting for at least half of Slide’s revenues, and that ...

Confirm Biosciences (@ConfirmBio) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Confirm Biosciences @ ConfirmBio ...

Microsoft Evangelist confirm Windows Phone 7 handsets will be upgraded to Windows Phone 8 - YouTube
Microsoft Evangelist confirm Windows Phone 7 handsets will be upgraded to Windows Phone 8 - YouTube

OPCW refuses to confirm nature of besieged Syria weapons depot
The UN chemical weapons watchdog would not say if the bunker, reported to contain sarin, was on a list submitted by Damascus that locates its ...

Mexican authorities confirm burnt-out van with two bodies belongs to missing Australian surfers
Mexican authorities confirm a burnt-out van with two bodies did belong to two missing West Australian surfers.

Bugatti confirms new Chiron to debut in Geneva
Filed under: Geneva Motor Show , Bugatti , Supercars Bugatti confirmed the Veyron's highly anticipated successor will be called the Chiron and ...

Top Apple insider confirms a new 4-inch iPhone is coming in early 2016
We heard rumors earlier this week about Apple planning to release a new 4-inch "iPhone 6c" in February 2016 but we didn't give them that much ...

People: Sandra Bullock confirms adoption of three year-old daughter, Laila
When Sandra Bullock was promoting her film, Our Brand is Crisis , she was asked about the rumors that she had adopted a daughter . Those stories ...

Resources last updated: 12/5/2015 2:32:23 PM