|
Thanks for your reply
Please send some tutorial about the conference chatting.all added users can send their messages and display it on the same window..
|
|
|
|
|
Hi..
I have a UserControl named MyControl.I have placed a Button on this UserControl.I placed this UserControl on my webForm named Default.aspx.My requirement is to raise CustomEvent when i click the Button.
This is the code i tried.....
//in MyControl.ascx.cs
public event System.EventHandler Hello;
//in Button_click event
this.Hello(this, new EventArgs());
//in default.aspx.cs
protected MyControl MyControl1;
//in page_Load
this.MyControl.Hello +=new
EventHandler(MyControl_Hello);
//after Page_load
private void MyControl_Hello(object sender, EventArgs e)
{
Response.Write("welcome");
}
----------------------------------------------------------------------------
i am able to print "welcome" in 1.1 version.Above code is working fine.but in 2.o its not working.i need this in 2.0.plz anyone help me.....................
|
|
|
|
|
Seems ok. But if you are not using "EventArgs e" you pass null instead of "new EventArgs();".
and on the other hand i think it is better to initialize event handlers in OnInit instead of Page_Load..
What do you think guys?
|
|
|
|
|
what you told is exactly correct.bcoz i got error
object ref is not set to an instance of an object.but i am not getting how to handle it.i thought u hav a good knowledge on this topic.plz help me...(wats the code i need to write)
|
|
|
|
|
//in MyControl.ascx.cs
public event System.EventHandler Hello;
//in Button_click event
///I suggest:
if(this.Hello != null) this.Hello(this, null);
//in default.aspx.cs
protected MyControl MyControl1;
//in page_Load XX
///override OnInit
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.MyControl.Hello +=new
EventHandler(MyControl_Hello);
}
//after Page_load
private void MyControl_Hello(object sender, EventArgs e)
{
//this is not a good way put a label and assing your value to it
Response.Write("welcome");
}
|
|
|
|
|
hi...
still i am getting same error.plzzzz check once again the code u posted.
|
|
|
|
|
man i don't know then your problem is something else,
try giving more detail about the error
|
|
|
|
|
Hi,
I have used javascript confirmation on button click.On button click confirmation message pop up correctly.
I have "update()" and "addnew()" function calls in button click event,If user click button confirmation message should get pop up and on confirmation
"update()" function should get called else "AddNew()" function should get called.
I hope someone know solution plz share ur idea with me.
Thanks,
Nagraj.
|
|
|
|
|
Response.Write( "<script language='JavaScript'>" +
" function showAchPendingMsg() { " +
" var pendingConfirmation = window.confirm('PG');" +
" if (pendingConfirmation == true) { ShowDetail()"+
" } else { DoShow()"+
" " +
" } " +
" }" +
" showAchPendingMsg();" +
" function DoShow() { alert('else');}"+
" function ShowDetail() { alert('if');}"+
"<" + "/" + "script>");
|
|
|
|
|
RegisterClientScriptBlock is better, and you didn't show him how to hook the call into his click event, either.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Is this the code wot u were talking about ? If yes will u plz lemme know why it is better?
string scriptString =( "" +
" function showAchPendingMsg() { " +
" var pendingConfirmation = window.confirm('PG');" +
" if (pendingConfirmation == true) { ShowDetail()"+
" } else { DoShow()"+
" " +
" } " +
" }" +
" showAchPendingMsg();" +
" function DoShow() { alert('else');}"+
" function ShowDetail() { alert('if');}"+
"<" + "/" + "script>");
string scriptName = "Confirm";
if(!Page.IsClientScriptBlockRegistered(scriptName);)
{
Page.RegisterClientScriptBlock(scriptName,scriptString);
}
|
|
|
|
|
He is telling instead of using Response.Write to send JS script, use RegisterClientScript which is in page object.
|
|
|
|
|
Yeah I understood.. But now I just want to know how it is better.. what is the utility of it.
|
|
|
|
|
What did you exactly tried to do with the Response.Write method? Let me say that clearly - You tried to Register blocks of client-side script containing functions . Microsoft has provide a method very specific to perform this particular task 'RegisterClientScriptBlock' .
Response.write Method is meant for writting a specified string to the current HTTP output. The specified string can be a Dynamically Build Javascript Code. But it's well suitable for a Javascript Alert message when we try to write Javascript code on the client using Response.Write(), Not for Registering blocks of client-side script containing functions. There are many ways to solve a problem. The question is Are we doing it the right way, the best way?
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
This is not the exact difference. Response.Write() places the string (in this case dynamic JS code) supplied on the top of the page, that is outside HTML tag. But using the specified methods to emit client script ensures that it is inside the DOM. You can use either RegisterClientScriptBlock() or RegisterStartupScript() for injecting JS code to the page.
More over, RegisterStartupScript() executes before the page's OnLoad() event fires.
|
|
|
|
|
Thanks!!! Thats wot I wanted to know, If I am doing something I should know why I am doing so...
|
|
|
|
|
N a v a n e e t h wrote: This is not the exact difference
Did I explain about the Differences? I guess No. I tried to compare with what Prateek did with Response.Write() and What Could have been done.
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
John Prabhu wrote: Did I explain about the Differences?
He was asking about why use client script methods to register instead of Response.Write. But your answer was not fully explaining. So I guessed you were comparing Response.Write and the other and given my reply.
|
|
|
|
|
i want to use images that is randomly generating codes in my sign up form. i got some sample programs from a site. but in this, the image is showing on the top left corner of the page. but i want to show it in a perticular place in my form. how to do it. plz help me...
|
|
|
|
|
|
here its using Response.BinaryWrite(); to display image.
plz check this link http://www.aspspider.net/resources/Resource272.aspx
|
|
|
|
|
The only way you can use binarywrite to place an image in a page is if you register a custom file type to handle a URL and write the image back. This is commonly what CAPTHA systems do
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi All,
I am using StoreProcedure to delete Row .I have passed Parameter GroupId to StoreProcedure ,to delete row.I am using Datasource to bind data in data grid .I want to delete Row from GridView ,onClick of Delete. But What is happening is,When i click on select then I need to click on Delete and It gets delete. I want to delete On click of delete.
Help me Plz.
Pallav
|
|
|
|
|
Place a delete button in the gridview and then on click of that button call the stored procedure to delete the row. And after deleting the row bind the gridview again.
Apurva Kaushal
|
|
|
|
|