|
How do I stop the postback from a asp button? I want to do some validation on
the client side when a button is pressed and decide whether to post back to
the server or not.
Thanks
Hari
|
|
|
|
|
Hi Hari
you can do this by adding small attribute(JavaScript function) to Button.
on form load event of code behind file
<Your Button Name>.Attributes.Add("OnClick", "return confirm('Continue?');");
or
<asp:Button ID="btnSample" runat="server" Text="View Detail"
OnClientClick="return confirm('Continue?');" />
hope this Help
Thanks..
|
|
|
|
|
Hi TRK@UK,
Thanks for the response, this is working fine as expected.
I tried something more...
In Page Load
--
Object objAjax = Request.QueryString["from"];
if (objAjax != null)
{
Response.Clear();
Response.Write("1");
Response.End();
}
Button1.Attributes.Add("OnClick", " var finalval = chkText(); if(finalval == false){return false;}");
---
<script language="javascript" type="text/javascript">
var XmlHttp;
function chkText()
{
try
{
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e1)
{
XmlHttp = null;
}
}
if(!XmlHttp && typeof XMLHttpRequest != "undefined")
{
XmlHttp = new XMLHttpRequest();
}
if(XmlHttp)
{
try
{
XmlHttp.onreadystatechange = HandleResponse;
XmlHttp.open("POST", "CallingServerFunctionUsingAjax.aspx?from=Ajax",true);
XmlHttp.send(null);
if(XmlHttp.readyState==1)
{
return false;
}
}
catch(e2)
{
alert(e2);
}
}
}
function HandleResponse()
{
try
{
if(XmlHttp.readyState == 4)
{
if(XmlHttp.status == 200)
{
var retval=XmlHttp.responseText;
switch(retval)
{
case "1":
return false;
break;
default:
break;
}
}
else
{
alert("Problem with saving data");
}
}
}
catch(e)
{
alert("Error");
}
}
</script>
But the function chkText() is not acepting the return value....
What is the problem.........
Thanks
Hari
|
|
|
|
|
Alternatively, if you're using 2.0, the buttons expose an OnClientClick attribute which fires (on the client side obviusly, so you'll need to give it a javascript function) before OnClick...to stop OnClick, return false from OnClientClick
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Hi RichardGrimmer,
Great.It did the trick...
Thanks for the reply...
Thanks
Hari
|
|
|
|
|
I have a repeater displaying repeated rows, trying to figure a way to keep the first appearence and remove the next but it is not working
how can i detect a first ocurrence of a record and add a e.Item.visible = false here?
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (Convert.ToString(((Label)e.Item.FindControl("itemselected")).Text) != "")
{
((CheckBox)e.Item.FindControl("selectitem")).Checked = true;
}
//fstk.STOCK_ID as fsselected
if (Convert.ToString(((Label)e.Item.FindControl("fsselected")).Text) != "")
{
((CheckBox)e.Item.FindControl("selectitem")).Checked = true;
((CheckBox)e.Item.FindControl("selectitem")).Enabled = false;
}
|
|
|
|
|
Hi Techies !
Ive got a modal popup window opening through a link on my page.
I need to find which page is opening the popup window at runtime.
Javascript gives the required value through window.dialogArguments.location.href
but i wana do this through my C# code.
can someone plz guide ?
Marching towards Geek-Age !
- Prasadd
|
|
|
|
|
How to apply styles to ajax tab control.
vijaykrishna v
|
|
|
|
|
|
Hi
Installing Ajax toolkit itself not enough to see Controls on your IDE.
To See Ajax Toolkit in your ToolBox Rightclick on toolbox and chooseItems then Browse add
Reference to "AjaxControlToolkit.dll"
This DLL Avilable @ \SampleWebSite\Bin\AjaxControlToolkit.dll
you will see all Ajax cotrols in your toolbox.Drag n drop controls you wish to use.
|
|
|
|
|
i seem to have a problem it keep saying it need atag called asp:scriptmanager
however when i try to add it in the page dont regconize it
<asp:ScriptManager runat="Server" EnableScriptGlobalization="true" EnableScriptLocalization="true" /
|
|
|
|
|
Hi
Try this
place "ScriptManager" Tag after the 'Form' tag(First Control to Appear in Form).
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<table>
<tr>
<td align="left">
<asp:TextBox ID="txtSeatSince" runat="server" Width="96px" Enabled="false" ></asp:TextBox>
<ajaxToolkit:CalendarExtender Format="dd/MM/yyyy" ID="CalendarExtender1"
runat="server" TargetControlID="txtSeatSince">
</ajaxToolkit:CalendarExtender>
</td>
</tr>
</table>
</div>
</form>
thanks
|
|
|
|
|
Hello Friends,
I am facing an parser error
Parser Error Message: The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception
Please provide me any sollution why this error their.
On local mine project is working fine but on server it is generating this error.
Please help
Regards,
rahul saini
|
|
|
|
|
Hi
What is your problem please give some detail
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
hi guys any one know how to get the datetime picker control from the window application side of microsoft visual studio to the asp.net side of it?
or how to use ajax to get the control?
|
|
|
|
|
Windows --> Web? Are you Kidding !!!!
|
|
|
|
|
Hi,
I'm working on ASP.NET 2.0, I have set of .aspx pages,codebehind files and some reference classes under App_code folder. My Queries are:
1) If I wanna to move the application to the target server (Production server) which are all the files I should move?
2) In ASP.NET 2.0 no dll files are generated for website projects, then is it safe to deploy aspx.cs files as well?
Please its urgent..help me out in this
Thanks in advance
M-o-h-a-n
|
|
|
|
|
M-o-h-a-n wrote: If I wanna to move the application to the target server (Production server) which are all the files I should move?
Aspx, cs, config files.
M-o-h-a-n wrote: In ASP.NET 2.0 no dll files are generated for website projects, then is it safe to deploy aspx.cs files as well?
If you have doubt on security then you can go for publish website option. That will generate dll's and you can upload that along with the ASPX files.
|
|
|
|
|
Thanks Navaneeth
M-o-h-a-n
|
|
|
|
|
navneeth, I'm back with few queries again In VS 2003 we can configure the build or output type for Website project to dll rite? why I don't find any such options in VS 2005 Team Edition? Can you help me on this?
M-o-h-a-n
|
|
|
|
|
We are working on a project on web mail server. can anybody have any idea on how to configure smtp server means whether to make account of all the users on the smtp server or in database and than attach it to smtp server to authenticate users.its urgent please.
thanx in advance
prashant jain malviya national institute of technology
|
|
|
|
|
Hi, how can i export an excel file from a datagrid.
When I am exporting a set of numbers like this 54564564588956 .. the excel file is showing me as this: 5422F12
Why is this?? Can someone help me on this problem!! Its killing me
Adrian De Battista - Web Designer, Web Programmer, Software Programmer From Malta. My Website .. www.MaltaTrade.org
|
|
|
|
|
Hello,
if your DataGrid name is dgGrid then try the following code
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw =
new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();
dgGrid.DataSource = dsExport;
// Get the HTML for the control.
dgGrid.HeaderStyle.Font.Bold = true;
dgGrid.DataBind();
dgGrid.RenderControl(hw);
// Write the HTML back to the browser.
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();
Mehedi Hasan
|
|
|
|
|
Hi,
The problem remains the same but .. when I am exporting a large set of numbers the excel is showing them as this 4433F12 and I am exporting the number like this 4433131123342342
How can i solve this problem pls
Adrian De Battista - Web Designer, Web Programmer, Software Programmer From Malta. My Website .. www.MaltaTrade.org
|
|
|
|
|
I want to send the mails by using the particular IP. bu default it take local ip but i want it to be changed.
Mohinder Singh
|
|
|
|