tag:blogger.com,1999:blog-20390765251664510492024-03-13T12:05:42.968-07:00E. Ateş GÜRALE. Ateş GÜRALhttp://www.blogger.com/profile/14787494489008761814noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2039076525166451049.post-83732840642521279332016-04-29T13:35:00.001-07:002016-04-29T13:36:34.233-07:00Yüzler<br />
<div>
Unutmam gereken yüzler var diyorum sana</div>
<div>
Söylenmesi gereken sözler…</div>
<div>
Hadi onları bırak kenara</div>
<div>
Yıkanması gereken kirlerim var,</div>
<div>
Yakılması gereken anılarım.</div>
<div>
<br /></div>
<div>
Toplasan anıları bir saat etmez,</div>
<div>
Bu ömür keşkeleri saymaya yetmez…</div>
<div>
Uzansam dokunmak için şimdi çocukluğuma</div>
<div>
Arada yıllar dolu engeller var…</div>
E. Ateş GÜRALhttp://www.blogger.com/profile/14787494489008761814noreply@blogger.com0tag:blogger.com,1999:blog-2039076525166451049.post-23337957548330653412012-01-26T00:53:00.000-08:002015-04-11T04:59:27.847-07:00How to fire click event of a button in ASP.NET with JavaScriptI was working on ASP.NET, had to open a confirm box in a UserControl, I achieved it after some searches on the web.I used ScriptManager.RegisterStartupScript because I had UpdatePanels.That is how I called the JS function from code behind<br />
<br />
<blockquote>
<br />
string privateChatUyeHesapAdi = BAL.Cari.Cari.GetCariHesapAdi(i);<br />
<br />
string jsMethodForPrivateChat = "privatechatRequestConfirmation('" + privateChatUyeHesapAdi + "')";<br />
ScriptManager.RegisterStartupScript(UpdtPnlOzelSohbetButton, UpdtPnlOzelSohbetButton.GetType(), "confirmprivatechatrequest", jsMethodForPrivateChat, true);</blockquote>
<br />
And this is the JS function<br />
<blockquote>
function privatechatRequestConfirmation(uyeHesapAdi) {<br />
confirm(uyeHesapAdi + " wants to chat. ");<br />
}</blockquote>
<br />
<br />
Afterwards, it turned out that I need to some stuff according to the return value of the confirmation, which is pretty normal but as a noob I couldn't guess it at the beginning, and I changed my JS function to this<br />
<br />
<blockquote>
function privatechatRequestConfirmation(uyeHesapAdi) {<br />
var isConfirmed = confirm(uyeHesapAdi + " wants to chat ");<br />
}</blockquote>
<br />
Now, I have the return value in isConfirmed variable.<br />
What I need to do is basically click a button on the UserControl.<br />
I said to myself "I did this before, it's easy.Just get the element with client id and call click().".Tried it like this<br />
<blockquote>
document.getElementById('<%= BttnKickMembersForPrivateChat.ClientID %>').click();</blockquote>
<br />
Well, I got that JavaScript error saying "click is not defined".Damn...<br />
I tried not using ClienID or tried OnClick = true insted of click().None of them worked.<br />
After some researches I ended up with __doPostBack() method, actually it is like this <br />
<blockquote>
__doPostBack(eventTarget, eventArgument)</blockquote>
<br />
So it takes a target control and a event argument, from <a href="http://wiki.asp.net/404.aspx?aspxerrorpath=/themes/fan/pages/page.aspx/1082/dopostback-function/">wiki.asp.net __doPostBack function</a> I figured out that I can send my button name as eventTarget and OnClick as eventArgument I tried it like this<br />
<blockquote>
__doPostBack('BttnKickMembersForPrivateChat', 'OnClick');</blockquote>
<br />
Well, it didn't fire that button's onclick event then I tried<br />
<blockquote>
__doPostBack('BttnKickMembersForPrivateChat', 'BttnKickMembersForPrivateChat_Click');</blockquote>
<br />
BttnKickMembersForPrivateChat_Click is the name of onclick event on code-behind, but again it didn't fire.<br />
Then I realized the 5th step of that link on wiki.asp.net<br />
In the PageLoad method:<br />
<br />
<blockquote>
<br />
if (Request.Form["__EVENTTARGET"] == "Button2")<br />
{<br />
//fire event<br />
Button2_Click(this, new EventArgs());<br />
}</blockquote>
<br />
<br />
And I added that part in my Page_Load, well I saw that I obviously do not need the click event now, "just write a method Ateş, and call that" I said to myself and I did.<br />
<br />
In my Page_Load method<br />
<blockquote>
if (Request.Form["__EVENTTARGET"] == "BttnKickMembersForPrivateChat")
<br />
{<br />
method();//just a method to do what I want<br />
} <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-gER-cksgQsA/T8h0EzW6XwI/AAAAAAAAAKE/QGudKwHEqNQ/s1600/dotnetjs.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="256" src="http://4.bp.blogspot.com/-gER-cksgQsA/T8h0EzW6XwI/AAAAAAAAAKE/QGudKwHEqNQ/s320/dotnetjs.jpg" width="256" /></a></div>
<br /></blockquote>
<br />
<br />
It works perfectly for now, when isConfirmed is true, postback occurs and Page_Load method fires, then the if condition gives me what I want.<br />
<br />
<br />
References:<br />
Check<a href="http://weblogs.asp.net/yousefjadallah/archive/2010/06/27/insure-that-dopostback-function-implemented-on-the-page.aspx"> Ensure that __doPostBack() function is implemented on the page</a>E. Ateş GÜRALhttp://www.blogger.com/profile/14787494489008761814noreply@blogger.com0tag:blogger.com,1999:blog-2039076525166451049.post-85252999180171499472011-12-01T02:09:00.000-08:002015-04-11T04:59:27.861-07:00Repeater disappears on postbackLately I've been struggling with an ASP.NET Repeater control that holds some other controls in it which dynamically gets loadad with data.<br />I seemed to have one problem that whenever a postback occurs the repeater was disappearing.As much as I learned from my searches on the internet Repeater control is a dynamic control that needs to be databinded at every postback, I also learned that Page_Load is late for databinding to the repeater and it should be done in Repeater's Init method.<br />I really don't like these kind of controls but they are very handy in some cases, especially when you need to show dynamic or huge amount of records.In my scenario there were the categories and products at the top of the page you can add new category which is not in repeater but when add button is clicked repeater needs to be refreshed because it holds the categories list, and for deletion this is the same.<br /><br />After all, I found out that my solution is about the ViewState, the repeater's EnableViewState property was set to false I turned it to true and nothing else was needed.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-DluqdNrxvXo/T8hwxgTgj9I/AAAAAAAAAJo/c7OVzVLuFik/s1600/ASP.NET.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="200" width="200" src="http://1.bp.blogspot.com/-DluqdNrxvXo/T8hwxgTgj9I/AAAAAAAAAJo/c7OVzVLuFik/s320/ASP.NET.jpg" /></a></div>
<br />Here are some links I found benefitial:<br /><a href="http://www.codeproject.com/Articles/175032/Repeaters-and-Lost-Data-After-Postback-Viewstate">Repeaters and Lost Data After Postback (Viewstate)</a><br /><a href="http://www.velocityreviews.com/forums/t100555-viewstate-and-repeater-control.html">ViewState and Repeater Control</a><br /><a href="http://www.velocityreviews.com/forums/t699418-repeater-databinding-on-postback-and-base-databind.html">Repeater DataBinding on PostBack and base.DataBind()</a>E. Ateş GÜRALhttp://www.blogger.com/profile/14787494489008761814noreply@blogger.com0tag:blogger.com,1999:blog-2039076525166451049.post-43151441394457792152011-11-28T00:01:00.000-08:002015-04-11T04:59:27.855-07:00Changing the language of AJAX Control Toolkit Calender Extender ControlIf you are using Ajax control tool kit then you have a Script manager on your aspx file, and it probably looks like this<br /><br /><blockquote>asp:ScriptManager ID="ScriptManager1" runat="server"</blockquote><br /><br />Well, this will let you work with Ajax controls.However your calender extender's language will probably be English.If you need to change calender extender's culture what you need to do is below<br />Step 1: Check if you between your <span style="font-style:italic;"><@ Page /></span> tag you have set Culture as you wish it to be such as <span style="font-style:italic;">Culture="tr-TR"</span><br />Step 2: Add <span style="font-style:italic;">EnableScriptGlobalization</span> to your script manager, and set it <span style="font-style:italic;">True</span> then you will have<br /><blockquote>asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true"</blockquote><br />
<a href="http://4.bp.blogspot.com/-zkwsGw4Pt08/T9YARuW5x9I/AAAAAAAAAKg/UHfckhiZPZg/s1600/Untitled.png" imageanchor="1" style="clear:right; float:center; margin-left:250px; margin-bottom:1em"><img border="0" height="210" width="181" src="http://4.bp.blogspot.com/-zkwsGw4Pt08/T9YARuW5x9I/AAAAAAAAAKg/UHfckhiZPZg/s320/Untitled.png" /></a>
<br />This will probably work, you can also check for another ways to do this on <a href="http://lancezhang.wordpress.com/2009/01/09/change-culture-calendarextender/">How to change the Culture of CalendarExtender programmatically</a>.E. Ateş GÜRALhttp://www.blogger.com/profile/14787494489008761814noreply@blogger.com1