Monday, August 15, 2011

Pass TextBox ID to javascript function


TextBox2.Attributes.Add("onkeyup", "Fill('" + TextBox1.ClientID.ToString() + "','" + TextBox2.ClientID.ToString() + "','" + TextBox3.ClientID.ToString() + "')")
 

<script type="text/javascript">
    function Fill(x, y, z) 
    {
            val1 = parseFloat(document.getElementById(x).value);
            val2 = parseFloat(document.getElementById(y).value);   
//code here         
    }
    </script>
 

Thursday, August 4, 2011

Light Box withing GridView Template Feild.

Hi,
In my web application there was a function to send Messages. I used jquery Light Box to pop up the message form. But when i hit GridView button for each row, it display only firstly created light box every time. Take a lookat code so u can understand.

<ItemTemplate>
<asp:Label ID="mn" runat="server" Text='<%#Eval("MobileToNum") %>' CssClass="dn"></asp:Label>
<a href="#" runat="server" id="cli" data-reveal-id="m" class="phone-number-click my-anc"><img src="../images/SMS.jpg" /></a>

<asp:Label ID="smsresultlbl" runat="server" Font-Size="XX-Small" Font-Bold="true"></asp:Label>
   <div id="m" class="reveal-modal mydiv">
   <table class="noborder">
<tr>
<td>Mobile No:</td><td><asp:TextBox ID="mobileNoTxt" runat="server" CssClass="textarea-medium"></asp:TextBox><%-- <asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter Mobile Number" ControlToValidate="mobileNoTxt" ValidationGroup="sms" Display="Dynamic"></asp:RequiredFieldValidator>--%></td>
</tr>
<tr><td></td><td><asp:Button ID="confirmbtn" runat="server" onclick="confirmbtn_Click" Text="Send"></asp:Button></td></tr>
</table>
   <a class="close-reveal-modal">×</a>
  </div>  
                </ItemTemplate>
 
The reason was data-reveal-id and pop up div id not in same name. I used javascript code for match these.

<script type="text/javascript">

     $(".phone-number-click").click(function() {
         //console.log($("span", $(this).parent()).html());
         $("#" + $(this).attr("mobnum")).val($("span", $(this).parent()).html());
     });

     $(".my-anc").each(function(e) {
         var id = "id-" + e;
         $(this).attr("data-reveal-id", id);
         $(".mydiv:eq(" + e + ")").attr("id", id);
     });

   </script>
 

Wednesday, August 3, 2011

CS0123: No overload for 'smsbtn_Click' matches delegate 'System.EventHandler'

There was a ImageButton in my aspx page.

protected void smsbtn_Click(object sender, ImageClickEventArgs e)
{
}

I changed the code. I used LinkButton instead of ImageButton.
protected void smsbtn_Click(object sender, ImageClickEventArgs e)
{
}

But i fogot to change the ImageClickEventArgs to EventArgs. That was the reason for getting this error. :)

Tuesday, August 2, 2011

A potentially dangerous Request.QueryString value was detected from the client (M=""'>").

I saw this strange error when i request a page. The reason was i have registered a usercontrol which was not in project.

<%@ Register src="../../UserControl/SearchCurrency.ascx" tagname="SearchCurrency" tagprefix="uc1" %>

Simply remove it, now works fine :)

How to Create Events Using Microsoft Graph API with Delegated Permissions and MSAL.js

Microsoft Graph API provides powerful capabilities to interact with Microsoft 365 services. In this guide, we’ll explore how to create calen...