|
Try This one,
Use this code in your Code Behind
Page.ClientScript.RegisterStartupScriptthis.GetType(), "JSFunc", "MyFunc();", true);
This is your JavaScript Code :
<script type="text/javascript">
function MyFunc()
{
alert('JS Calling From Code Behind');
}
</script>
Hope this will help you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
thankz Abhijit Jana
Dre@m is not th@t wh@t u see in sleep.Dre@m is the thing which does not allow u to sleep
|
|
|
|
|
Page.ClientScript wont work in case if you are using AJAX in your page.At that time use Scriptmanager to register the clientscrit as
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), this.ClientID, "MyFunc();", true);
Rest will same as Abhijit said.
Cheers!!
Brij
|
|
|
|
|
you can also achive same thing by using jquery. and for more detail check jquery documentation on jquery site
<script type="text/javascript" src="JavaScript/jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
alert('page loaded');
});
|
|
|
|
|
Hi,
method1. code behind: this.Page.RegisterStartupScript(string key, string script);
method2. put your javascript function content(just the content) in the *.aspx body or div.
modified 27-May-14 4:57am.
|
|
|
|
|
I added checkbox on gridview this method:
asp:TemplateField>
<
ItemTemplate>
<
asp:CheckBox runat="server" ID="CheckBox1" />
</
ItemTemplate>
I want to save selected values another table but I did not achive.First I try this code and then I will convert this delete statement to select statement ,it deletes checked value but there is sql exception ID =@ID and keyid=@keyid"; I think this values should be primary key,but I cant set primary key in a table both of them(keyid my primary key now I need this primary key when user select one row ).Please give idea,I tried most of things and tired
string connStr = ConfigurationManager.ConnectionStrings["bdConnectionString"].ConnectionString;
string sql = "Delete From ekleme Where ID =@ID and keyid=@keyid";
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandType =
CommandType.Text;
SqlParameter keyid = cmd.Parameters.Add("@keyid", SqlDbType.Int);
SqlParameter ID = cmd.Parameters.Add("@ID", SqlDbType.Int);
keyid.Value = Session[
"keyid"];
string str = "";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
bool isChecked =((CheckBox)row.FindControl("CheckBox1")).Checked;
if (isChecked)
{
str =
"Seçildi";
conn.Open();
ID.Value = GridView1.Rows[i].Cells[0].Text;
cmd.ExecuteNonQuery();
}
}
Response.Write(str);
|
|
|
|
|
How to use Timer to refresh this Code
Visitors online: <%= Application["OnlineUsers"].ToString() %>
in regular intervals without refreshing the whole page !
|
|
|
|
|
Have the variable in a small DIV. Have a small window.setTimeout function to be called repeatedly based on timer and use XmlHttpRequest to fetch the value from the server and paint the DIV alone.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
Sorry !
I am Shame to say that ....
Will you please
give example Step by Step so i can understand it better (Cause i am new to ASP.net) and have to finish my project for this Wednesday !?
|
|
|
|
|
Try looking at this Linky[^]
modified on Tuesday, January 12, 2010 11:28 AM
|
|
|
|
|
<big>No Link !!!!!!!!!!!!!!!!!!</big>
|
|
|
|
|
|
Link fixed above
and try not to use <pre></pre> unless your submitting code of somekind
|
|
|
|
|
Thanks
You mean that i use this code
<pre>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Visitors online: <%= Application["OnlineUsers"].ToString() %>
</ContentTemplate>
</asp:UpdatePanel>
</pre>
|
|
|
|
|
HI all,
I have a problem with the printing documents from the remote system.
can any one tell me how can i do it ? (In C#).
Thanks in advance.
|
|
|
|
|
sarang_k wrote: I have a problem
What is the problem/error that you are getting?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
Hello guys;
How can I use JavaScript to hide server control like (asp:panel).
Thanks.
|
|
|
|
|
use javascript
document.getElementById('panel').style.display = 'none'
good luck
|
|
|
|
|
First you have to have the clientid of the panel in JS.Sample code
<script type="text/javascript"><br />
var panelClientID="<%=panelId.ClientID%>"<br />
function HidePanel()<br />
{<br />
document.getElementById(panelClientID).style.display='none';<br />
}<br />
</script><br />
Now put this code in your page and just change
panelId to your
PanelId and call the HidePanel() mathod from where you want.
Similarly you can do from other server side controls.
Cheers!!
Brij
|
|
|
|
|
It worked fine! Thanks.
I tried to use 'display' as a value in place of 'none' to see if i could display the hidden panel but it returned error.
Please help me out.
|
|
|
|
|
Is your problem resolved?
Cheers!!
Brij
|
|
|
|
|
Hi,
How to fix the above error.
Thanks and regards,
Amit Patel
|
|
|
|
|
can you please explain more in detail.
|
|
|
|
|
Menu control in asp.net slow down on mouse hover when loading large data.This problem occurs in IE 7.0.
But this problem resolve little bit by adding
in the master page.But it changes the font of all pages.
Can anyone comes across this type of problem?
or
How to increase the performance of the mouse hover on menu control in IE7.0
|
|
|
|
|
I think one thing you can do is store your menu data in cach that means you cash your data
i tried this and its working for me.
|
|
|
|